Skip to content

Commit 01c98d1

Browse files
authored
fix: fix heading in list item (#2520)
fix: fix heading in code in list item
1 parent c906a1f commit 01c98d1

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/Tokenizer.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ export class Tokenizer {
226226
if (!endEarly) {
227227
const nextBulletRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])((?: [^\\n]*)?(?:\\n|$))`);
228228
const hrRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`);
229-
const fencesBeginRegex = new RegExp(`^( {0,${Math.min(3, indent - 1)}})(\`\`\`|~~~)`);
229+
const fencesBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`);
230+
const headingBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`);
230231

231232
// Check if following lines should be included in List Item
232233
while (src) {
@@ -244,7 +245,7 @@ export class Tokenizer {
244245
}
245246

246247
// End list item if found start of new heading
247-
if (this.rules.block.heading.test(line)) {
248+
if (headingBeginRegex.test(line)) {
248249
break;
249250
}
250251

test/specs/new/list_code_header.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<ul>
2+
<li>list <h1 id="header">header</h1></li>
3+
</ul>

test/specs/new/list_code_header.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- list
2+
# header

0 commit comments

Comments
 (0)