fix: continue a block quote paragraph with a lazy line that starts an html tag (#4202)

* fix: continue a block quote paragraph with a lazy line that starts an html tag

A lazy continuation line in a block quote that is only an html tag, like
`</span>` or `<a href="bar">`, was lexed as an html block, which ended the
paragraph. An html block of type 7 cannot interrupt a paragraph, so the
line continues the paragraph, as in CommonMark.

* refactor: move the lazy html paragraph check to the tokenizer
This commit is contained in:
yash
2026-11-13 11:19:55 -07:00
committed by GitHub
parent 738ebebc83
commit 8a578e4c0c
3 changed files with 39 additions and 0 deletions
+6
View File
@@ -626,6 +626,12 @@ export class _Tokenizer<ParserOutput = string, RendererOutput = string> {
html(src: string): Tokens.HTML | undefined {
const cap = this.rules.block.html.exec(src);
if (cap) {
// an html block of type 7 cannot interrupt a paragraph, so a lazy
// continuation line that starts one continues the paragraph instead
if (this.lexer.state.lastToken?.type === 'paragraph' && !this.rules.other.htmlBeginRegex(4).test(src)) {
return;
}
const raw = trimTrailingBlankLines(cap[0]);
const token: Tokens.HTML = {
type: 'html',
@@ -0,0 +1,20 @@
<blockquote>
<p>foo
</span></p>
</blockquote>
<blockquote>
<p>foo
<a href="bar">
baz</p>
</blockquote>
<blockquote>
<blockquote>
<p>foo
</em></p>
</blockquote>
</blockquote>
<blockquote>
<p>foo</p>
</blockquote>
<div>
</div>
@@ -0,0 +1,13 @@
> foo
</span>
> foo
<a href="bar">
> baz
> > foo
</em>
> foo
<div>
</div>