Skip to content

Commit 1d4d8fe

Browse files
amanjhacodes55amanclaude
authored
fix: only close a code fence with the opening fence character (#4164)
Co-authored-by: aman <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 64a299d commit 1d4d8fe

3 files changed

Lines changed: 32 additions & 1 deletion

File tree

‎src/rules.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export const other = {
118118

119119
const newline = /^(?:[ \t]*(?:\n|$))+/;
120120
const blockCode = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
121-
const fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
121+
const fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}(?:(?=`)\1`*|(?=~)\1~*) *(?=\n|$)|$)/;
122122
const hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
123123
const heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
124124
const bullet = / {0,3}(?:[*+-]|\d{1,9}[.)])/;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<pre><code>code
2+
```~~~
3+
still code
4+
</code></pre>
5+
6+
<pre><code>code
7+
~~~```
8+
still code
9+
</code></pre>
10+
11+
<pre><code>code
12+
</code></pre>
13+
14+
<p>after</p>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
```
2+
code
3+
```~~~
4+
still code
5+
```
6+
7+
~~~
8+
code
9+
~~~```
10+
still code
11+
~~~
12+
13+
```
14+
code
15+
`````
16+
17+
after

0 commit comments

Comments
 (0)