fix: fix Setext continuation in blockquote (#3257)
This commit is contained in:
parent
a90223b680
commit
e9f0eed707
@ -156,7 +156,9 @@ export class _Tokenizer {
|
||||
blockquote(src: string): Tokens.Blockquote | undefined {
|
||||
const cap = this.rules.block.blockquote.exec(src);
|
||||
if (cap) {
|
||||
const text = rtrim(cap[0].replace(/^ *>[ \t]?/gm, ''), '\n');
|
||||
// precede setext continuation with 4 spaces so it isn't a setext
|
||||
let text = cap[0].replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g, '\n $1');
|
||||
text = rtrim(text.replace(/^ *>[ \t]?/gm, ''), '\n');
|
||||
const top = this.lexer.state.top;
|
||||
this.lexer.state.top = true;
|
||||
const tokens = this.lexer.blockTokens(text);
|
||||
|
@ -58,7 +58,7 @@ const html = edit(
|
||||
const paragraph = edit(_paragraph)
|
||||
.replace('hr', hr)
|
||||
.replace('heading', ' {0,3}#{1,6}(?:\\s|$)')
|
||||
.replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
|
||||
.replace('|lheading', '') // setext headings don't interrupt commonmark paragraphs
|
||||
.replace('|table', '')
|
||||
.replace('blockquote', ' {0,3}>')
|
||||
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
|
||||
@ -117,7 +117,7 @@ const blockGfm: Record<BlockKeys, RegExp> = {
|
||||
paragraph: edit(_paragraph)
|
||||
.replace('hr', hr)
|
||||
.replace('heading', ' {0,3}#{1,6}(?:\\s|$)')
|
||||
.replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
|
||||
.replace('|lheading', '') // setext headings don't interrupt commonmark paragraphs
|
||||
.replace('table', gfmTable) // interrupt paragraphs with table
|
||||
.replace('blockquote', ' {0,3}>')
|
||||
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
|
||||
|
@ -743,8 +743,7 @@
|
||||
"example": 93,
|
||||
"start_line": 1527,
|
||||
"end_line": 1537,
|
||||
"section": "Setext headings",
|
||||
"shouldFail": true
|
||||
"section": "Setext headings"
|
||||
},
|
||||
{
|
||||
"markdown": "- Foo\n---\n",
|
||||
|
@ -743,8 +743,7 @@
|
||||
"example": 93,
|
||||
"start_line": 1527,
|
||||
"end_line": 1537,
|
||||
"section": "Setext headings",
|
||||
"shouldFail": true
|
||||
"section": "Setext headings"
|
||||
},
|
||||
{
|
||||
"markdown": "- Foo\n---\n",
|
||||
|
19
test/specs/new/blockquote_setext.html
Normal file
19
test/specs/new/blockquote_setext.html
Normal file
@ -0,0 +1,19 @@
|
||||
<blockquote>
|
||||
<p>not heading 1 ==</p>
|
||||
</blockquote>
|
||||
|
||||
<blockquote>
|
||||
<p>not heading 2 --</p>
|
||||
</blockquote>
|
||||
|
||||
<blockquote>
|
||||
<h1>heading 1</h1>
|
||||
</blockquote>
|
||||
|
||||
<blockquote>
|
||||
<h2>heading 2</h2>
|
||||
</blockquote>
|
||||
|
||||
<blockquote>
|
||||
<p>not heading 1 == not heading 2 with br<br />--</p>
|
||||
</blockquote>
|
16
test/specs/new/blockquote_setext.md
Normal file
16
test/specs/new/blockquote_setext.md
Normal file
@ -0,0 +1,16 @@
|
||||
> not heading 1
|
||||
==
|
||||
|
||||
> not heading 2
|
||||
--
|
||||
|
||||
> heading 1
|
||||
> ==
|
||||
|
||||
> heading 2
|
||||
> --
|
||||
|
||||
> not heading 1
|
||||
==
|
||||
> not heading 2 with br
|
||||
--
|
@ -4,8 +4,6 @@
|
||||
<p>fenced code block</p>
|
||||
<pre><code>=
|
||||
</code></pre>
|
||||
<blockquote><h1>blockquote</h1>
|
||||
</blockquote>
|
||||
<h3>heading</h3>
|
||||
<p>=</p>
|
||||
<html>
|
||||
|
@ -6,9 +6,6 @@ fenced code block
|
||||
=
|
||||
```
|
||||
|
||||
> blockquote
|
||||
=
|
||||
|
||||
### heading
|
||||
=
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user