Repository navigation
Keep the last closer position in the backtick cache - #632
Open
yuxi-liu-wired wants to merge 1 commit into
Open
yuxi-liu-wired wants to merge 1 commit into
yuxi-liu-wired wants to merge 1 commit into
Conversation
scan_to_closing_backticks records, for each backtick-string length, the
position of the last such string it saw, so a later opener can tell
there is no closer without rescanning. A scan that starts after an
earlier one had already reached the end of the input overwrote a later
position with an earlier one. A following opener of that length then
saw a closer position before itself and gave up:
``x
`i`
`j`
rendered `` `j` `` as text instead of a code span. Store a position only
if it is past the one already recorded.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
scan_to_closing_backticksrecords, per backtick-string length, the position of the last such string it saw, so that a later opener can tell without rescanning that no closer is left. A scan that starts after an earlier scan had already reached the end of the input overwrote a later position with an earlier one. A following opener of that length then saw a recorded position before itself and gave up:cmark renders
`j`as text:commonmark.js (and pulldown-cmark) give two code spans, as the spec does:
`j`has a matching closer.The fix stores a position only if it is past the one already recorded.
Test: a new example in
test/regression.txt, next to the other code examples. It fails on master and passes with the change. Spec 652/652, pathological 25/25, and the Linux half of ci.yml passes locally (gcc/clang, shared/static, with and without ASan/UBSan).Found by differential fuzzing of pulldown-cmark against cmark, with commonmark.js as tie-breaker.