Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix html following list #3444

Merged
merged 1 commit into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>