From 9d7b7287495d719e0a9c5d4def403a6d0284a20d Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Sun, 8 Sep 2024 09:25:54 -0600 Subject: [PATCH] fix: fix html following list (#3444) --- src/Tokenizer.ts | 6 ++++++ test/specs/new/html_following_list.html | 7 +++++++ test/specs/new/html_following_list.md | 5 +++++ 3 files changed, 18 insertions(+) create mode 100644 test/specs/new/html_following_list.html create mode 100644 test/specs/new/html_following_list.md diff --git a/src/Tokenizer.ts b/src/Tokenizer.ts index 80fc59ec..f29795e7 100644 --- a/src/Tokenizer.ts +++ b/src/Tokenizer.ts @@ -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) { @@ -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; diff --git a/test/specs/new/html_following_list.html b/test/specs/new/html_following_list.html new file mode 100644 index 00000000..349d4136 --- /dev/null +++ b/test/specs/new/html_following_list.html @@ -0,0 +1,7 @@ + +
+Content +
diff --git a/test/specs/new/html_following_list.md b/test/specs/new/html_following_list.md new file mode 100644 index 00000000..52c21131 --- /dev/null +++ b/test/specs/new/html_following_list.md @@ -0,0 +1,5 @@ +- list item 1 +- list item 2 +
+Content +