Skip to content

Commit

Permalink
fix: fix html following list (#3444)
Browse files Browse the repository at this point in the history
  • Loading branch information
UziTech authored Sep 8, 2024
1 parent 2fe4136 commit 9d7b728
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Tokenizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ export class _Tokenizer {
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 headingBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`);
const htmlBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}<[a-z].*>`, 'i');

// Check if following lines should be included in List Item
while (src) {
Expand All @@ -330,6 +331,11 @@ export class _Tokenizer {
break;
}

// End list item if found start of html block
if (htmlBeginRegex.test(nextLine)) {
break;
}

// End list item if found start of new bullet
if (nextBulletRegex.test(nextLine)) {
break;
Expand Down
7 changes: 7 additions & 0 deletions test/specs/new/html_following_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<ul>
<li>list item 1</li>
<li>list item 2</li>
</ul>
<div class="some-class">
Content
</div>
5 changes: 5 additions & 0 deletions test/specs/new/html_following_list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- list item 1
- list item 2
<div class="some-class">
Content
</div>

0 comments on commit 9d7b728

Please sign in to comment.