Repository navigation
Skip the leading spaces of a lazy continuation line - #634
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
A paragraph line's leading spaces and tabs are not part of the
paragraph's raw content (spec 4.8), and cmark skips them for a normal
continuation line. A lazy continuation line was added from the current
offset instead, so its leading space stayed in the content. That shows
in a code span, where the line ending becomes a space:
> `a
b`
rendered `<code>a b</code>` (two spaces); commonmark.js gives
`<code>a b</code>`. The same in a list item (`- \`c\n d\``).
Advance past the leading whitespace before adding the lazy line, as the
non-lazy paragraph path does.
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.
The leading spaces and tabs of a paragraph line are not part of the paragraph's raw content (spec 4.8, "Paragraphs"), and cmark skips them for a normal continuation line. A lazy continuation line was added from the current offset instead, so its leading whitespace stayed in the content. Mostly that is invisible, since inline parsing strips it again after a soft break, but in a code span the line ending turns into a space and the extra space stays:
cmark renders
<code>a b</code>and<code>c d</code>(two spaces). commonmark.js (and pulldown-cmark) give<code>a b</code>and<code>c d</code>, the same as without the container (`a\n b`gives<code>a b</code>in cmark too).The fix advances past the leading whitespace before adding the lazy line, as the non-lazy paragraph path already does.
Test: a new example in
test/regression.txt, after the indented-continuation (Springfield) example. It fails on master and passes with the change. Spec 652/652, pathological 25/25.Found by differential fuzzing of pulldown-cmark against cmark, with commonmark.js as tie-breaker.