fix: no strikethrough on different number of tildes (#1821)

Possible Breaking Change: When using the inline.del rule the text is provided in capture group 2 instead of 1.
This commit is contained in:
Tony Brix 2020-11-14 20:03:39 -06:00 committed by GitHub
parent 73f10d3a9a
commit d79f210aba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 3 deletions

View File

@ -585,7 +585,7 @@ module.exports = class Tokenizer {
return { return {
type: 'del', type: 'del',
raw: cap[0], raw: cap[0],
text: cap[1] text: cap[2]
}; };
} }
} }

View File

@ -318,8 +318,8 @@ inline.gfm = merge({}, inline.normal, {
_extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/, _extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
_backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/, _backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
del: /^~+(?=\S)([\s\S]*?\S)~+/, del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
text: /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*~]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))/ text: /^([`~]+|[^`~])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*~]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))/
}); });
inline.gfm.url = edit(inline.gfm.url, 'i') inline.gfm.url = edit(inline.gfm.url, 'i')

View File

@ -0,0 +1,16 @@
<p><del>test</del></p>
<p>~~test~</p>
<p>~test~~</p>
<p><del>test</del></p>
<p><del>test
test</del></p>
<p>~~test</p>
<p>test~~</p>
<pre><code class="language-test~~~"></code></pre>

View File

@ -0,0 +1,16 @@
~~test~~
~~test~
~test~~
~test~
~~test
test~~
~~test
test~~
~~~test~~~