mirror of
https://github.com/markedjs/marked.git
synced 2026-11-30 16:48:05 +01:00
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:
@@ -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>
|
||||
Reference in New Issue
Block a user