fix: Fix spurious deeper nesting in a blockquote continuation (#4030)

This commit is contained in:
spokodev
2026-08-03 22:31:16 -06:00
committed by GitHub
parent e8544e6a67
commit 452f1ed6a7
3 changed files with 17 additions and 2 deletions
+7 -2
View File
@@ -200,11 +200,16 @@ export class _Tokenizer<ParserOutput = string, RendererOutput = string> {
} else if (lastToken?.type === 'blockquote') {
// include continuation in nested blockquote
const oldToken = lastToken as Tokens.Blockquote;
const newText = oldToken.raw + '\n' + lines.join('\n');
// The continuation lines belong to the same nesting frame as the
// nested blockquote, which already had one '>' marker stripped, so
// strip one marker from them too. Otherwise a restated marker after a
// lazy line is re-parsed as a spurious deeper blockquote.
const continuation = lines.join('\n');
const newText = oldToken.raw + '\n' + continuation.replace(this.rules.other.blockquoteSetextReplace2, '');
const newToken = this.blockquote(newText)!;
tokens[tokens.length - 1] = newToken;
raw = raw.substring(0, raw.length - oldToken.raw.length) + newToken.raw;
raw = `${raw}\n${continuation}`;
text = text.substring(0, text.length - oldToken.text.length) + newToken.text;
break;
} else if (lastToken?.type === 'list') {
@@ -0,0 +1,7 @@
<blockquote>
<blockquote>
<p>a
b
c</p>
</blockquote>
</blockquote>
@@ -0,0 +1,3 @@
> > a
b
> > c