mirror of
https://github.com/markedjs/marked.git
synced 2026-11-30 16:48:05 +01:00
fix: fix empty heading breaks paragraph and table (#3050)
This commit is contained in:
+3
-3
@@ -131,7 +131,7 @@ block.lheading = edit(block.lheading)
|
||||
|
||||
block.paragraph = edit(block._paragraph)
|
||||
.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('|table', '')
|
||||
.replace('blockquote', ' {0,3}>')
|
||||
@@ -164,7 +164,7 @@ block.gfm = {
|
||||
|
||||
block.gfm.table = edit(block.gfm.table as Rule)
|
||||
.replace('hr', block.hr)
|
||||
.replace('heading', ' {0,3}#{1,6} ')
|
||||
.replace('heading', ' {0,3}#{1,6}(?:\\s|$)')
|
||||
.replace('blockquote', ' {0,3}>')
|
||||
.replace('code', ' {4}[^\\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)
|
||||
.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('table', block.gfm.table as RegExp) // interrupt paragraphs with table
|
||||
.replace('blockquote', ' {0,3}>')
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<p>Newline after heading</p>
|
||||
<h2></h2>
|
||||
|
||||
<p>No newline at the end</p>
|
||||
<h2></h2>
|
||||
@@ -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
|
||||
##
|
||||
@@ -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>
|
||||
@@ -0,0 +1,13 @@
|
||||
| a | b |
|
||||
| - | - |
|
||||
| 1 | 2 |
|
||||
| 3 | 4 |
|
||||
##
|
||||
|
||||
No newline at the end
|
||||
|
||||
| a | b |
|
||||
| - | - |
|
||||
| 1 | 2 |
|
||||
| 3 | 4 |
|
||||
##
|
||||
Reference in New Issue
Block a user