Skip to content

Commit 0afe87d

Browse files
authoredNov 7, 2024··
fix: fix del with escaped tilde (#3517)
* fix: fix del with escaped tilde * use rules to check for unescaped tilde * add tests with spaces
1 parent a612576 commit 0afe87d

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed
 

‎src/rules.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ const inlineGfm: Record<InlineKeys, RegExp> = {
301301
.replace('email', /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/)
302302
.getRegex(),
303303
_backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
304-
del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
304+
del: /^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,
305305
text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/,
306306
};
307307

‎test/specs/new/escape_within_del.html

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<p><del>\</del></p>
2+
<p>~\~</p>
3+
<p><del>~</del></p>
4+
<p>~\~~</p>
5+
<p>~~ ~</p>
6+
<p>~ ~~</p>

‎test/specs/new/escape_within_del.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
~\\~
2+
3+
~\\\~
4+
5+
~\~~
6+
7+
~\\~~
8+
9+
~\~ ~
10+
11+
~ \~~

0 commit comments

Comments
 (0)
Please sign in to comment.