sopel-irc / sopel-github

GitHub plugin for Sopel

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Simplistic filtering of headings in comment body

dgw opened this issue · comments

commented

This code is a bit too simplistic:

and not line.startswith('#') # Markdown heading

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.

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

commented

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.

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