atom / language-gfm

GitHub Flavored Markdown in Atom
MIT License
101 stars 108 forks source link

Improved ATX Heading Regex #222

Open Aerijo opened 6 years ago

Aerijo commented 6 years ago

Requirements

Description of the Change

Updates the header patterns to follow the specifications given here closer.

This PR is necessary to prevent things like

#
text

from having text incorrectly scoped as a heading. It allows for the 'empty' heading, which is a legal heading. That bug was caused by the (\\s*) pattern in the original, which would also capture the endline character and hide it from the end pattern, causing it to end on the following line (and scoping that line as a heading).

Screenshot

screen shot 2017-12-24 at 7 33 59 pm

Alternate Designs

As far as I can tell, these headings must be a single line. Therefore, I could have used a match pattern instead, but I didn't because the existing ones were begin/end patterns.

Benefits

More accurate syntax highlighting, in line with the specifications of the language.

Possible Drawbacks

Some GFM implementations might not follow the specifications so rigouously? They are new, after all.

Other than that, I don't know any drawbacks.

Applicable Issues

None.

Additional notes

I did not change the specs because they still pass with this change. I could add more though, to prevent regressions from this PR.