Skip to content

Commit 1d7272f

Browse files
b84330808claude
andauthored
fix: keep a block quote open after a lazy line in a nested block quote (#4175)
After a lazy continuation line in a nested block quote, a following line that starts with ">" but does not continue the inner paragraph (a blank ">", a heading, a thematic break, a list item, ...) started a new top-level block quote. It belongs to the outer block quote, as in CommonMark. Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 2d4a23c commit 1d7272f

3 files changed

Lines changed: 53 additions & 0 deletions

File tree

‎src/Tokenizer.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,13 @@ export class _Tokenizer<ParserOutput = string, RendererOutput = string> {
285285
raw = `${raw}\n${consumed.join('\n')}`;
286286
}
287287
text = text.substring(0, text.length - oldToken.text.length) + newToken.text;
288+
289+
// A leftover line that starts with '>' still belongs to this
290+
// blockquote; any other leftover line ends it.
291+
lines = lines.slice(consumed.length);
292+
if (lines.length > 0 && this.rules.other.blockquoteStart.test(lines[0])) {
293+
continue;
294+
}
288295
break;
289296
} else if (lastToken?.type === 'list') {
290297
// include continuation in nested list
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<blockquote>
2+
<blockquote>
3+
<p>a
4+
b</p>
5+
</blockquote>
6+
<p>c</p>
7+
</blockquote>
8+
<blockquote>
9+
<blockquote>
10+
<p>a
11+
b</p>
12+
</blockquote>
13+
<h1>heading</h1>
14+
</blockquote>
15+
<blockquote>
16+
<blockquote>
17+
<p>a
18+
b</p>
19+
</blockquote>
20+
<hr>
21+
</blockquote>
22+
<blockquote>
23+
<blockquote>
24+
<p>a
25+
b</p>
26+
</blockquote>
27+
<ul>
28+
<li>item</li>
29+
</ul>
30+
</blockquote>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
> > a
2+
b
3+
>
4+
> c
5+
6+
> > a
7+
b
8+
> # heading
9+
10+
> > a
11+
b
12+
> ---
13+
14+
> > a
15+
b
16+
> - item

0 commit comments

Comments
 (0)