This repository has been archived by the owner on Dec 15, 2022. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Requirements
Description of the Change
Updates the header patterns to follow the specifications given here closer.
^\\s{,3}
- allow up to three spaces at the start of the line(#{1})
- number of#
characters((?:\\s*?(?=$))|(?:\\s+(?=[^$])))
- two possible situtations:(?:\\s*?(?=$))
- the last#
is followed by 0 or more spaces that end with a newline character. Non greedy, so the newline character is not captured.(?:\\s+(?=[^$]))
- the last#
is followed by 1 or more spaces (greedy), and stops just before the first non-endline characterThis 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 theend
pattern, causing it to end on the following line (and scoping that line as a heading).Screenshot
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 werebegin/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.