diff --git a/src/Tokenizer.ts b/src/Tokenizer.ts index e6f900d457..2b15fe2dc6 100644 --- a/src/Tokenizer.ts +++ b/src/Tokenizer.ts @@ -200,11 +200,16 @@ export class _Tokenizer { } 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') { diff --git a/test/specs/new/blockquote_nested_lazy_continuation.html b/test/specs/new/blockquote_nested_lazy_continuation.html new file mode 100644 index 0000000000..ef017d70c7 --- /dev/null +++ b/test/specs/new/blockquote_nested_lazy_continuation.html @@ -0,0 +1,7 @@ +
+
+

a +b +c

+
+
diff --git a/test/specs/new/blockquote_nested_lazy_continuation.md b/test/specs/new/blockquote_nested_lazy_continuation.md new file mode 100644 index 0000000000..045c52ebe2 --- /dev/null +++ b/test/specs/new/blockquote_nested_lazy_continuation.md @@ -0,0 +1,3 @@ +> > a +b +> > c