diff --git a/src/rules.ts b/src/rules.ts index aa23c9b4..5086d19a 100644 --- a/src/rules.ts +++ b/src/rules.ts @@ -118,7 +118,7 @@ export const other = { const newline = /^(?:[ \t]*(?:\n|$))+/; const blockCode = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/; -const fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/; +const fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}(?:(?=`)\1`*|(?=~)\1~*) *(?=\n|$)|$)/; const hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/; const heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/; const bullet = / {0,3}(?:[*+-]|\d{1,9}[.)])/; diff --git a/test/specs/new/fence_closing_mixed_characters.html b/test/specs/new/fence_closing_mixed_characters.html new file mode 100644 index 00000000..d6572174 --- /dev/null +++ b/test/specs/new/fence_closing_mixed_characters.html @@ -0,0 +1,14 @@ +
code
+```~~~
+still code
+
+ +
code
+~~~```
+still code
+
+ +
code
+
+ +

after

diff --git a/test/specs/new/fence_closing_mixed_characters.md b/test/specs/new/fence_closing_mixed_characters.md new file mode 100644 index 00000000..43a4f2d9 --- /dev/null +++ b/test/specs/new/fence_closing_mixed_characters.md @@ -0,0 +1,17 @@ +``` +code +```~~~ +still code +``` + +~~~ +code +~~~``` +still code +~~~ + +``` +code +````` + +after