fix: fix empty heading breaks paragraph and table (#3050)
This commit is contained in:
parent
39cee771b6
commit
a1034e6dd1
@ -131,7 +131,7 @@ block.lheading = edit(block.lheading)
|
|||||||
|
|
||||||
block.paragraph = edit(block._paragraph)
|
block.paragraph = edit(block._paragraph)
|
||||||
.replace('hr', block.hr)
|
.replace('hr', block.hr)
|
||||||
.replace('heading', ' {0,3}#{1,6} ')
|
.replace('heading', ' {0,3}#{1,6}(?:\\s|$)')
|
||||||
.replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
|
.replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
|
||||||
.replace('|table', '')
|
.replace('|table', '')
|
||||||
.replace('blockquote', ' {0,3}>')
|
.replace('blockquote', ' {0,3}>')
|
||||||
@ -164,7 +164,7 @@ block.gfm = {
|
|||||||
|
|
||||||
block.gfm.table = edit(block.gfm.table as Rule)
|
block.gfm.table = edit(block.gfm.table as Rule)
|
||||||
.replace('hr', block.hr)
|
.replace('hr', block.hr)
|
||||||
.replace('heading', ' {0,3}#{1,6} ')
|
.replace('heading', ' {0,3}#{1,6}(?:\\s|$)')
|
||||||
.replace('blockquote', ' {0,3}>')
|
.replace('blockquote', ' {0,3}>')
|
||||||
.replace('code', ' {4}[^\\n]')
|
.replace('code', ' {4}[^\\n]')
|
||||||
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
|
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
|
||||||
@ -175,7 +175,7 @@ block.gfm.table = edit(block.gfm.table as Rule)
|
|||||||
|
|
||||||
block.gfm.paragraph = edit(block._paragraph)
|
block.gfm.paragraph = edit(block._paragraph)
|
||||||
.replace('hr', block.hr)
|
.replace('hr', block.hr)
|
||||||
.replace('heading', ' {0,3}#{1,6} ')
|
.replace('heading', ' {0,3}#{1,6}(?:\\s|$)')
|
||||||
.replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
|
.replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
|
||||||
.replace('table', block.gfm.table as RegExp) // interrupt paragraphs with table
|
.replace('table', block.gfm.table as RegExp) // interrupt paragraphs with table
|
||||||
.replace('blockquote', ' {0,3}>')
|
.replace('blockquote', ' {0,3}>')
|
||||||
|
5
test/specs/new/empty_heading_following_paragraph.html
Normal file
5
test/specs/new/empty_heading_following_paragraph.html
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<p>Newline after heading</p>
|
||||||
|
<h2></h2>
|
||||||
|
|
||||||
|
<p>No newline at the end</p>
|
||||||
|
<h2></h2>
|
5
test/specs/new/empty_heading_following_paragraph.md
Normal file
5
test/specs/new/empty_heading_following_paragraph.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
Newline after heading
|
||||||
|
##
|
||||||
|
|
||||||
|
No newline at the end
|
||||||
|
##
|
@ -0,0 +1,5 @@
|
|||||||
|
<p>Newline after heading</p>
|
||||||
|
<h2></h2>
|
||||||
|
|
||||||
|
<p>No newline at the end</p>
|
||||||
|
<h2></h2>
|
@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
gfm: false
|
||||||
|
---
|
||||||
|
Newline after heading
|
||||||
|
##
|
||||||
|
|
||||||
|
No newline at the end
|
||||||
|
##
|
41
test/specs/new/empty_heading_following_table.html
Normal file
41
test/specs/new/empty_heading_following_table.html
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>a</th>
|
||||||
|
<th>b</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>1</td>
|
||||||
|
<td>2</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>3</td>
|
||||||
|
<td>4</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<h2></h2>
|
||||||
|
|
||||||
|
<p>No newline at the end</p>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>a</th>
|
||||||
|
<th>b</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>1</td>
|
||||||
|
<td>2</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>3</td>
|
||||||
|
<td>4</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<h2></h2>
|
13
test/specs/new/empty_heading_following_table.md
Normal file
13
test/specs/new/empty_heading_following_table.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
| a | b |
|
||||||
|
| - | - |
|
||||||
|
| 1 | 2 |
|
||||||
|
| 3 | 4 |
|
||||||
|
##
|
||||||
|
|
||||||
|
No newline at the end
|
||||||
|
|
||||||
|
| a | b |
|
||||||
|
| - | - |
|
||||||
|
| 1 | 2 |
|
||||||
|
| 3 | 4 |
|
||||||
|
##
|
Loading…
x
Reference in New Issue
Block a user