fix: keep empty list after blockquote as a sibling block (#4004)

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.
This commit is contained in:
spokodev
2026-07-14 16:08:05 -06:00
committed by GitHub
parent 0de7188bf1
commit 3f144a0e93
3 changed files with 23 additions and 2 deletions
+4 -2
View File
@@ -177,8 +177,10 @@ const createParagraph = (listInterrupt: RegExp) => edit(_paragraph)
// only non-empty lists starting from 1 can interrupt paragraphs
const paragraph = createParagraph(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/);
// blockquotes can be interrupted by lists starting from any number
const blockquoteParagraph = createParagraph(/ {0,3}(?:[*+-]|\d{1,9}[.)])[ \t]+[^ \t\n]/);
// inside a blockquote a bare list marker (any number) starts a sibling list,
// so it must not be lazily continued as paragraph text (unlike a top level
// paragraph, where an empty list cannot interrupt)
const blockquoteParagraph = createParagraph(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/);
const blockquote = edit(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/)
.replace('paragraph', blockquoteParagraph)
@@ -0,0 +1,13 @@
<blockquote>
<p>foo</p>
</blockquote>
<ul>
<li></li>
</ul>
<blockquote>
<p>foo
bar</p>
</blockquote>
<ol>
<li></li>
</ol>
@@ -0,0 +1,6 @@
> foo
-
> foo
> bar
1.