Skip to content

Commit

Permalink
fix: fix del with escaped tilde (#3517)
Browse files Browse the repository at this point in the history
* fix: fix del with escaped tilde

* use rules to check for unescaped tilde

* add tests with spaces
  • Loading branch information
UziTech authored Nov 7, 2024
1 parent a612576 commit 0afe87d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ const inlineGfm: Record<InlineKeys, RegExp> = {
.replace('email', /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/)
.getRegex(),
_backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
del: /^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,
text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/,
};

Expand Down
6 changes: 6 additions & 0 deletions test/specs/new/escape_within_del.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<p><del>\</del></p>
<p>~\~</p>
<p><del>~</del></p>
<p>~\~~</p>
<p>~~ ~</p>
<p>~ ~~</p>
11 changes: 11 additions & 0 deletions test/specs/new/escape_within_del.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
~\\~

~\\\~

~\~~

~\\~~

~\~ ~

~ \~~

0 comments on commit 0afe87d

Please sign in to comment.