fix: fix del with escaped tilde (#3517)

* fix: fix del with escaped tilde

* use rules to check for unescaped tilde

* add tests with spaces
This commit is contained in:
Tony Brix 2024-11-07 10:23:40 -07:00 committed by GitHub
parent a612576ff6
commit 0afe87d7fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 1 deletions

View File

@ -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.!#$%&'*+\/=?_`{\|}~-]+@)))/,
};

View File

@ -0,0 +1,6 @@
<p><del>\</del></p>
<p>~\~</p>
<p><del>~</del></p>
<p>~\~~</p>
<p>~~ ~</p>
<p>~ ~~</p>

View File

@ -0,0 +1,11 @@
~\\~
~\\\~
~\~~
~\\~~
~\~ ~
~ \~~