mirror of
https://github.com/markedjs/marked.git
synced 2026-11-30 16:48:05 +01:00
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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
2d4a23c50e
commit
1d7272f9ca
@@ -285,6 +285,13 @@ export class _Tokenizer<ParserOutput = string, RendererOutput = string> {
|
||||
raw = `${raw}\n${consumed.join('\n')}`;
|
||||
}
|
||||
text = text.substring(0, text.length - oldToken.text.length) + newToken.text;
|
||||
|
||||
// A leftover line that starts with '>' still belongs to this
|
||||
// blockquote; any other leftover line ends it.
|
||||
lines = lines.slice(consumed.length);
|
||||
if (lines.length > 0 && this.rules.other.blockquoteStart.test(lines[0])) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
} else if (lastToken?.type === 'list') {
|
||||
// include continuation in nested list
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<blockquote>
|
||||
<blockquote>
|
||||
<p>a
|
||||
b</p>
|
||||
</blockquote>
|
||||
<p>c</p>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<blockquote>
|
||||
<p>a
|
||||
b</p>
|
||||
</blockquote>
|
||||
<h1>heading</h1>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<blockquote>
|
||||
<p>a
|
||||
b</p>
|
||||
</blockquote>
|
||||
<hr>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<blockquote>
|
||||
<p>a
|
||||
b</p>
|
||||
</blockquote>
|
||||
<ul>
|
||||
<li>item</li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
@@ -0,0 +1,16 @@
|
||||
> > a
|
||||
b
|
||||
>
|
||||
> c
|
||||
|
||||
> > a
|
||||
b
|
||||
> # heading
|
||||
|
||||
> > a
|
||||
b
|
||||
> ---
|
||||
|
||||
> > a
|
||||
b
|
||||
> - item
|
||||
Reference in New Issue
Block a user