According to http://github.github.com/github-flavored-markdown/preview.html
text like these bits:
_starts with underscore
_do_not_emphasize
should *not* be emphasized, because the paragraph ends with an unclosed "_".
Note that in this text:
one two _three
four five_ six
"three four five" only will be emphasized. Leaving the "_" off
after "five" leaves all text in both lines unemphasized.
I'm relying on http://github.github.com/github-flavored-markdown/preview.html
to determine the actual Markdown syntax, since the spec is minimal, even with
github saying the preview is deprecated.
OK. I'll leave this to anhy Markdown user.
Over five years later, same problem :(
Ideally, the parser would recognize that emphasis cannot span paragraphs. I guess checking for
[\r?\n][\r?\n]should be both minimal and sufficient.Patched by implementing the above suggestion of Bewied.[1]
Note that the corrected parsing rules don't conform to any standard, whether GitHub's [2] or otherwise.
In fact, GitHub's Markdown editor will only apply the emphatic style when a closing token is seen on the same line as the first:
Evidently Github's parser scans backward from the end of the style region, while
LexMarkdowndoes the opposite. Emulating the former's behaviour would involve a susbtantial re-write, and the original author's comments make clear that broad feature support was never part of the lexer's design.[1]: Two changed type specifiers and one cast were also added to weed out some more signed/unsigned mismatches; new tests are enclosed separately
[2]: This link was the best substitute I could find for the obsolete original one
On a second attempt, it wasn't that hard to get
LexMarkdownto behave in the GitHub way:It was just a matter of scanning forward for a closing emphasis marker.
Which one looks better is a matter of taste; but the original issue was really about compliance with GitHub's interpretation of Markdown syntax, so I guess this newer patch set is a better solution.
Note: the earlier test files had misspellings that have now been corrected.
The second approach, disallowing emphasis that is not closed, appears more correct to me so that has been committed as
https://github.com/ScintillaOrg/lexilla/commit/ca976aaa2d505e5d7fe5f11a2d7be9b610e2fac0
The type changes were separated and applied first as
https://github.com/ScintillaOrg/lexilla/commit/1ba3e848ab924c54856878880e8ed57cab609510