fix: only close a code fence with the opening fence character (#4164)

Co-authored-by: aman <aman@pronnel.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aman Jha
2026-11-02 07:57:23 -07:00
committed by GitHub
co-authored by aman Claude Opus 5.5
parent 64a299def9
commit 1d4d8fe6f5
3 changed files with 32 additions and 1 deletions
+1 -1
View File
@@ -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}[.)])/;
@@ -0,0 +1,14 @@
<pre><code>code
```~~~
still code
</code></pre>
<pre><code>code
~~~```
still code
</code></pre>
<pre><code>code
</code></pre>
<p>after</p>
@@ -0,0 +1,17 @@
```
code
```~~~
still code
```
~~~
code
~~~```
still code
~~~
```
code
`````
after