Repository navigation
Conversation
handle_close_bracket tracked whether any active link opener remained
with a single global flag on the subject (no_link_openers) rather than
the per-opener active bit the CommonMark algorithm uses. The flag is set
after a link is formed, so an outer ] that comes right after an inner
link is left literal (spec example 549). But push_bracket clears the
flag for every new [, so a bracket opened between the inner link and the
outer ] re-activates the still-open outer opener. When that ] is reached
the outer opener matches and wraps the inner link:
[foo [bar](/uri)[x]](/uri)
rendered <a> nested inside <a>, which the spec forbids ("Links may not
contain other links, at any level of nesting"). commonmark.js leaves
the outer brackets literal.
Use the active field already present on each bracket: the close-bracket
check consults opener->active, and forming a link deactivates every
remaining non-image opener on the stack, as commonmark.js does.
Regression tests added for the inline and reference-link forms.
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.
handle_close_brackettracked whether any active link opener remained with a single global flag on the subject (no_link_openers) rather than the per-opener active bit the CommonMark algorithm uses. The flag is set after a link is formed, so an outer]that comes right after an inner link is correctly left literal (spec example 549). Butpush_bracketclears the flag for every new[, so a bracket opened between the inner link and the outer]re-activates the still-open outer opener. When that]is reached the outer opener matches and wraps the inner link:rendered
<p><a href="/uri">foo <a href="/uri">bar</a>[x]</a></p>, an<a>inside an<a>, which the spec forbids ("Links may not contain other links, at any level of nesting"). commonmark.js gives<p>[foo <a href="/uri">bar</a>[x]](/uri)</p>.A single boolean cannot represent per-opener state. This switches to the
activefield already present on eachbracket: the close-bracket check consultsopener->active, and forming a link deactivates every remaining non-image opener on the stack, as commonmark.js does. Spec example 549 and nested images inside links are unaffected, and the full spec suite stays green.Regression tests added for the inline and reference-link forms.