mirror of
https://github.com/markedjs/marked.git
synced 2026-11-30 16:48:05 +01:00
fix: Fix spurious deeper nesting in a blockquote continuation (#4030)
This commit is contained in:
+7
-2
@@ -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
|
||||
Reference in New Issue
Block a user