Skip to content

Commit 5e5bd1f

Browse files
committed
fix: keep empty list after blockquote as a sibling block
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.
1 parent 33928d0 commit 5e5bd1f

3 files changed

Lines changed: 23 additions & 2 deletions

File tree

src/rules.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,10 @@ const createParagraph = (listInterrupt: RegExp) => edit(_paragraph)
177177

178178
// only non-empty lists starting from 1 can interrupt paragraphs
179179
const paragraph = createParagraph(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/);
180-
// blockquotes can be interrupted by lists starting from any number
181-
const blockquoteParagraph = createParagraph(/ {0,3}(?:[*+-]|\d{1,9}[.)])[ \t]+[^ \t\n]/);
180+
// inside a blockquote a bare list marker (any number) starts a sibling list,
181+
// so it must not be lazily continued as paragraph text (unlike a top level
182+
// paragraph, where an empty list cannot interrupt)
183+
const blockquoteParagraph = createParagraph(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/);
182184

183185
const blockquote = edit(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/)
184186
.replace('paragraph', blockquoteParagraph)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<blockquote>
2+
<p>foo</p>
3+
</blockquote>
4+
<ul>
5+
<li></li>
6+
</ul>
7+
<blockquote>
8+
<p>foo
9+
bar</p>
10+
</blockquote>
11+
<ol>
12+
<li></li>
13+
</ol>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
> foo
2+
-
3+
4+
> foo
5+
> bar
6+
1.

0 commit comments

Comments
 (0)