fix: keep text after empty nested blockquote (#4101)

fix: keep text after empty nested blockquote (#4098)

Only append continuation lines that the nested blockquote token actually
consumed, so following paragraphs and blockquotes are not skipped.

Co-authored-by: Bennett Payoyo <Yahiro025@users.noreply.github.com>
This commit is contained in:
Bennett Payoyo
2026-09-21 23:44:50 -06:00
committed by GitHub
co-authored by Bennett Payoyo
parent 7f7a49670c
commit 1b89557177
3 changed files with 48 additions and 1 deletions
+9 -1
View File
@@ -266,7 +266,15 @@ export class _Tokenizer<ParserOutput = string, RendererOutput = string> {
const newToken = this.blockquote(newText)!;
tokens[tokens.length - 1] = newToken;
raw = `${raw}\n${continuation}`;
// Only include continuation lines the nested blockquote actually
// consumed. Unconsumed trailing lines must stay out of `raw` so the
// lexer can still tokenize them (paragraph, next blockquote, etc.).
const leftover = newText.substring(newToken.raw.length).replace(/^\n/, '');
const leftoverCount = leftover ? leftover.split('\n').length : 0;
const consumed = leftoverCount ? lines.slice(0, -leftoverCount) : lines;
if (consumed.length > 0) {
raw = `${raw}\n${consumed.join('\n')}`;
}
text = text.substring(0, text.length - oldToken.text.length) + newToken.text;
break;
} else if (lastToken?.type === 'list') {
@@ -0,0 +1,26 @@
<blockquote>
<blockquote>
</blockquote>
</blockquote>
<p>text</p>
<blockquote>
<blockquote>
<blockquote>
</blockquote>
</blockquote>
</blockquote>
<p>text</p>
<blockquote>
<p>quote</p>
<blockquote>
</blockquote>
</blockquote>
<p>text</p>
<blockquote>
<blockquote>
</blockquote>
</blockquote>
<p>text</p>
<blockquote>
<p>more</p>
</blockquote>
@@ -0,0 +1,13 @@
>>
text
>>>
text
> quote
>>
text
>>
text
> more