fix: keep empty list after blockquote as a sibling block#4004
Open
spokodev wants to merge 1 commit into
Open
Conversation
A blockquote followed by a bare list marker line (for example
`> foo\n-`) wrongly nested an empty list inside the blockquote.
The blockquote regex reuses the paragraph list-interrupt clause
` {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]`, whose trailing `[ \t]+[^ \t\n]`
requires content after the marker. A bare marker line therefore was
not seen as an interruption and got lazily continued into the
blockquote paragraph, then re-lexed into a nested empty list.
Give the blockquote its own paragraph variant whose list-interrupt
clause also matches a bare marker, so the list ends the blockquote and
becomes a sibling block. The top level paragraph rule is unchanged, so
an empty list still cannot interrupt a paragraph.
|
@spokodev is attempting to deploy a commit to the MarkedJS Team on Vercel. A member of the Team first needs to authorize it. |
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.
Description
A blockquote immediately followed by a bare list marker line nests an empty list inside the blockquote instead of starting a sibling list.
Minimal repro
Expected (matches commonmark.js and markdown-it):
Actual:
Reproduces for
-,*,+,1.,1)and for multi line blockquotes (> foo\n> bar\n-). Non empty lists (> foo\n- bar) already behave correctly.Root cause
The
blockquoterule reuses the paragraph list interrupt clause:The trailing
[ \t]+[^ \t\n]requires content after the marker, which is correct for a top level paragraph (an empty list cannot interrupt a paragraph). But the same clause also controls when a blockquote stops its lazy continuation. A bare marker line does not match it, so the marker line is lazily continued into the blockquote paragraph and then re lexed into a nested empty list.Per CommonMark 0.31.2 (5.1 block quotes laziness, 5.2 list items) a list begun by a bare marker is a sibling block after the blockquote, not a lazy continuation of it. commonmark.js and markdown-it both produce the sibling.
Fix
Give the blockquote its own paragraph variant (
blockquoteParagraph) whose list interrupt clause also matches a bare marker:The top level
paragraphrule is left untouched, sofoo\n-(setext heading),foo\n*andfoo\n1.(no interruption) keep their current behavior. The change only affects when a blockquote ends.Relation to #4003
#4003 also routes the
blockquoterule through ablockquoteParagraphconst, but for a different bug (#4002, non empty ordered lists with a start other than 1). It keeps the[ \t]+[^ \t\n]content requirement, so it does not fix the empty marker case verified here. The two changes touch the same region; I can rebase or fold the two interrupt clauses into one if a maintainer prefers a single edit.Tests
test/specs/new/empty_list_after_blockquote.{md,html}covering the bare unordered and bare ordered cases including a multi line blockquote.npm testgreen, including the CommonMark and GFM conformance specs (1745 spec assertions, 188 unit tests).Contributor
Committer