diff --git a/src/Tokenizer.js b/src/Tokenizer.js index e8a69b6759..0f77a01050 100644 --- a/src/Tokenizer.js +++ b/src/Tokenizer.js @@ -226,6 +226,7 @@ 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)}})(\`\`\`|~~~)`); // Check if following lines should be included in List Item while (src) { @@ -237,6 +238,16 @@ export class Tokenizer { line = line.replace(/^ {1,4}(?=( {4})*[^ ])/g, ' '); } + // End list item if found code fences + if (fencesBeginRegex.test(line)) { + break; + } + + // End list item if found start of new heading + if (this.rules.block.heading.test(line)) { + break; + } + // End list item if found start of new bullet if (nextBulletRegex.test(line)) { break; diff --git a/test/specs/new/fences_following_list.html b/test/specs/new/fences_following_list.html new file mode 100644 index 0000000000..e5b2a9f9e7 --- /dev/null +++ b/test/specs/new/fences_following_list.html @@ -0,0 +1,7 @@ +
if {
+
+}
+
diff --git a/test/specs/new/fences_following_list.md b/test/specs/new/fences_following_list.md
new file mode 100644
index 0000000000..f306891f9c
--- /dev/null
+++ b/test/specs/new/fences_following_list.md
@@ -0,0 +1,5 @@
+1. abcd
+```
+if {
+}
+```
diff --git a/test/specs/new/fences_with_blankline_following_list_0.html b/test/specs/new/fences_with_blankline_following_list_0.html
new file mode 100644
index 0000000000..cc77e8b936
--- /dev/null
+++ b/test/specs/new/fences_with_blankline_following_list_0.html
@@ -0,0 +1,23 @@
+if {
+
+}
+
+if {
+
+}
+
+text after fenced code block.
+if {
+
+
+}
+
diff --git a/test/specs/new/fences_with_blankline_following_list_0.md b/test/specs/new/fences_with_blankline_following_list_0.md
new file mode 100644
index 0000000000..2ea9a26285
--- /dev/null
+++ b/test/specs/new/fences_with_blankline_following_list_0.md
@@ -0,0 +1,22 @@
+1. code with blankline
+```
+if {
+
+}
+```
+
+2. code and text
+```
+if {
+
+
+}
+```
+text after fenced code block.
+
+3. tilde
+~~~
+if {
+
+}
+~~~
diff --git a/test/specs/new/fences_with_blankline_following_list_1.html b/test/specs/new/fences_with_blankline_following_list_1.html
new file mode 100644
index 0000000000..31e59331ef
--- /dev/null
+++ b/test/specs/new/fences_with_blankline_following_list_1.html
@@ -0,0 +1,22 @@
+code with blankline
+if {
+
+}
+
+code and text
+if {
+
+}
+
+text after fenced code block.
+tilde
+if {
+
+
+}
+
+