Skip to content

Commit d848445

Browse files
authoredMar 6, 2024··
fix: fix setext heading interupts (#3210)
1 parent d61c266 commit d848445

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed
 

‎src/rules.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@ const fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\
1212
const hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
1313
const heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
1414
const bullet = /(?:[*+-]|\d{1,9}[.)])/;
15-
const lheading = edit(/^(?!bull )((?:.|\n(?!\s*?\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/)
15+
const lheading = edit(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/)
1616
.replace(/bull/g, bullet) // lists can interrupt
17+
.replace(/blockCode/g, / {4}/) // indented code blocks can interrupt
18+
.replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/) // fenced code blocks can interrupt
19+
.replace(/blockquote/g, / {0,3}>/) // blockquote can interrupt
20+
.replace(/heading/g, / {0,3}#{1,6}/) // ATX heading can interrupt
21+
.replace(/html/g, / {0,3}<[^\n>]+>\n/) // block html can interrupt
1722
.getRegex();
1823
const _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
1924
const blockText = /^[^\n]+/;
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<pre><code>indented code block
2+
</code></pre>
3+
<p>=</p>
4+
<p>fenced code block</p>
5+
<pre><code>=
6+
</code></pre>
7+
<blockquote><h1>blockquote</h1>
8+
</blockquote>
9+
<h3>heading</h3>
10+
<p>=</p>
11+
<html>
12+
=

‎test/specs/new/setext_no_blankline.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
indented code block
2+
=
3+
4+
fenced code block
5+
```
6+
=
7+
```
8+
9+
> blockquote
10+
=
11+
12+
### heading
13+
=
14+
15+
<html>
16+
=

0 commit comments

Comments
 (0)
Please sign in to comment.