Fix spurious deeper nesting in a lazy blockquote continuation#4030
Open
spokodev wants to merge 1 commit into
Open
Fix spurious deeper nesting in a lazy blockquote continuation#4030spokodev wants to merge 1 commit into
spokodev wants to merge 1 commit into
Conversation
In a nested blockquote, a paragraph line that lazily continues and is then followed by a line restating the `>` markers was parsed into an extra, spurious blockquote level (and a split paragraph) instead of continuing the same paragraph. The continuation branch re-lexes the nested blockquote from `oldToken.raw + '\n' + lines`, but `oldToken.raw` already had one `>` marker stripped for the inner frame while the appended `lines` still carry the outer markers, so a restated `> >` keeps one surplus `>` and is read as a fresh deeper blockquote. Strip one marker from the continuation lines (as the normal path does via `blockquoteSetextReplace2`) so they align with the inner frame, and rebuild `raw` from the actual consumed source. Both `commonmark` and `micromark` + GFM produce the merged, non-over-nested output this now matches.
|
@spokodev is attempting to deploy a commit to the MarkedJS Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Problem
In a nested blockquote, a paragraph line that lazily continues and is then
followed by a line restating the
>markers is parsed into an extra, spuriousblockquote level (and a split paragraph) instead of continuing the same
paragraph.
Input:
marked(before this PR):Expected — identical output from both
commonmark0.31.2 andmicromark+micromark-extension-gfm:> > a\nb\n> > > cshows the same off-by-one-level (4 blockquotes in marked vsthe correct 3). Plain lazy nesting without a restated marker
(
> > > foo\nbar, CommonMark example 250) is unaffected, which is why noexisting spec caught it.
Root cause
The nested-blockquote continuation branch re-lexes the inner blockquote from
oldToken.raw + '\n' + lines.join('\n').oldToken.rawalready had one>marker stripped for the inner frame, but the appended continuation
linesstillcarry the outer markers, so a restated
> >keeps one surplus>when recursedand is read as a fresh deeper blockquote that interrupts the open paragraph. The
single-level path works only because the marker is stripped there via
blockquoteSetextReplace2; this branch bypassed that strip.Fix
Strip one
>marker from the continuation lines (sameblockquoteSetextReplace2the normal path uses) so they align with the inner frame, and rebuild
rawfromthe actual consumed source. Deeper markers (
> > >) simply recurse one furtherlevel, which is correct.
Test
Added
test/specs/new/blockquote_nested_lazy_continuation(.md/.html).Fails on
master(2 failing spec cases), passes with the fix. Full suite green:test:specs1769 pass / 0 fail,test:unit188 pass / 0 fail.Reference: CommonMark 0.31.2 §6.3 (block quotes — laziness): a line beginning
with the blockquote's own markers followed by paragraph text continues that
paragraph, not a new deeper quote.