Skip to content

Commit

Permalink
fix: fix heading in list item (#2520)
Browse files Browse the repository at this point in the history
fix: fix heading in code in list item
  • Loading branch information
UziTech authored Jul 11, 2022
1 parent c906a1f commit 01c98d1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Tokenizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ export class Tokenizer {
if (!endEarly) {
const nextBulletRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])((?: [^\\n]*)?(?:\\n|$))`);
const hrRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`);
const fencesBeginRegex = new RegExp(`^( {0,${Math.min(3, indent - 1)}})(\`\`\`|~~~)`);
const fencesBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`);
const headingBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`);

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

// End list item if found start of new heading
if (this.rules.block.heading.test(line)) {
if (headingBeginRegex.test(line)) {
break;
}

Expand Down
3 changes: 3 additions & 0 deletions test/specs/new/list_code_header.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<ul>
<li>list <h1 id="header">header</h1></li>
</ul>
2 changes: 2 additions & 0 deletions test/specs/new/list_code_header.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- list
# header

1 comment on commit 01c98d1

@vercel
Copy link

@vercel vercel bot commented on 01c98d1 Jul 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.