Closed amohamed11 closed 2 years ago
Thanks for your PR, this looks simple and nice! It may be replaced once #182 is implemented, but that's not happening any time soon.
However, I think your regex is faulty. I played around and came up with (?m)^#[^#][\t ]*[^\s].*$
which I think is better. Anything can be in a header, but your regex disallows Unicode symbols. It also matches across newlines due to use of \s
.
If you didn't know already, you can test and play with your regex at https://regex101.com/. It's a great site and very handy for understanding regex and creating your own.
If you don't spot any issues with my regex, you can add it to this PR and I'll merge it after testing.
@makeworld-the-better-one ah good catch on the unicode, completely forgot to test for that. I tested your regex on a few examples, and it seemes to work well. I've updated the regex and amended the commit to keep things small. Let me know if there is anything else.
Thanks for this, works great! Will merge now. In the future, I prefer contributors avoid force-pushes / amending, so what was changed is clear. I will squash the commits after anyway.
Added basic top level 1
#
heading extraction to suggest it as title for bookmark. I'm a regex newbie, but this was the best regex I could come up with that handled most cases that I tested for. Any regex wizardry advice is welcome.Closes #267