sopel-irc / sopel-github

GitHub plugin for Sopel
Other
3 stars 13 forks source link

Simplistic filtering of headings in comment body #104

Closed dgw closed 1 year ago

dgw commented 2 years ago

This code is a bit too simplistic:

https://github.com/sopel-irc/sopel-github/blob/bb66e621512673dc446bb7801572a76301b190ec/sopel_modules/github/formatting.py#L83

It doesn't allow for one-line comments that start with an issue/PR/discussion reference, like this one I just left in Sopel's main repo.

Exirel commented 2 years ago

I think and not all(l == '#' for l in line) should do the trick.

dgw commented 2 years ago

Might want to think again. Markdown headings, like what we use in the issue templates for Sopel itself, are:

# Heading 1
## Heading 2
### Heading 3

And so on.

The whole line won't be just # characters. But it could work to check if line.split(' ', maxsplit=1)[0] is all #s, since Markdown headings are required to have a space between the # and the heading text.

Exirel commented 2 years ago

Ha! Indeed, I was thinking about rst heading. Maybe it's time for a regex then? Something like re.match(r'#+\s+.') maybe?