Skip to content

Commit afbb27c

Browse files
authored
fix: allow tabs in the thematic break that ends a list item (#4087)
CommonMark 0.31.2 says each -, _, or * of a thematic break may be followed by any number of spaces or tabs, but the hrRegex that closes a list item allowed spaces only, so a break written with tabs was taken as paragraph continuation instead. "- foo" followed by a line of underscores separated by tabs put the hr inside the list item, and "- foo" followed by "---" plus a tab turned foo into a setext heading. The block hr rule already allows tabs; this makes the list item check agree with it.
1 parent aed9336 commit afbb27c

3 files changed

Lines changed: 24 additions & 1 deletion

File tree

‎src/rules.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export const other = {
9393
endingNewline: /\n$/,
9494
listItemRegex: (bull: string) => new RegExp(`^( {0,3}${bull})((?:[\t ][^\\n]*)?(?:\\n|$))`),
9595
nextBulletRegex: cachedIndentRegex((indent: number) => new RegExp(`^ {0,${indent}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`)),
96-
hrRegex: cachedIndentRegex((indent: number) => new RegExp(`^ {0,${indent}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),
96+
hrRegex: cachedIndentRegex((indent: number) => new RegExp(`^ {0,${indent}}((?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\\*[ \t]*){3,})(?:\\n+|$)`)),
9797
fencesBeginRegex: cachedIndentRegex((indent: number) => new RegExp(`^ {0,${indent}}(?:\`\`\`|~~~)`)),
9898
headingBeginRegex: cachedIndentRegex((indent: number) => new RegExp(`^ {0,${indent}}#`)),
9999
htmlBeginRegex: cachedIndentRegex((indent: number) => new RegExp(`^ {0,${indent}}<(?:[a-z].*>|!--)`, 'i')),
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<ul>
2+
<li>foo</li>
3+
</ul>
4+
<hr>
5+
<ul>
6+
<li>bar</li>
7+
</ul>
8+
<hr>
9+
<ul>
10+
<li>baz</li>
11+
</ul>
12+
<hr>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
gfm: false
3+
---
4+
- foo
5+
_ _ _
6+
7+
- bar
8+
***
9+
10+
- baz
11+
---

0 commit comments

Comments
 (0)