diff --git a/src/rules.ts b/src/rules.ts index fd77781e..6b1ed331 100644 --- a/src/rules.ts +++ b/src/rules.ts @@ -277,11 +277,6 @@ const _punctuationGfmStrongEm = /(?!~)[\p{P}\p{S}]/u; const _punctuationOrSpaceGfmStrongEm = /(?!~)[\s\p{P}\p{S}]/u; const _notPunctuationOrSpaceGfmStrongEm = /(?:[^\s\p{P}\p{S}]|~)/u; -// GFM allows * and _ inside strikethrough -const _punctuationGfmDel = /(?![*_])[\p{P}\p{S}]/u; -const _punctuationOrSpaceGfmDel = /(?![*_])[\s\p{P}\p{S}]/u; -const _notPunctuationOrSpaceGfmDel = /(?:[^\s\p{P}\p{S}]|[*_])/u; - // sequences em should skip over [title](link), `code`, const blockSkip = edit(/link|precode-code|html/, 'g') .replace('link', /\[(?:[^\[\]`]|(?`+)[^`]+\k(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/) @@ -338,7 +333,7 @@ const emStrongRDelimUnd = edit( // Tilde left delimiter for strikethrough (similar to emStrongLDelim for asterisk) const delLDelim = edit(/^~~?(?:((?!~)punct)|[^\s~])/, 'u') - .replace(/punct/g, _punctuationGfmDel) + .replace(/punct/g, _punctuation) .getRegex(); // Tilde delimiter patterns for strikethrough (similar to asterisk) @@ -352,9 +347,9 @@ const delRDelimCore = + '|notPunctSpace(~~?)(?=notPunctSpace)'; // (6) a~~a can be either Left or Right Delimiter const delRDelim = edit(delRDelimCore, 'gu') - .replace(/notPunctSpace/g, _notPunctuationOrSpaceGfmDel) - .replace(/punctSpace/g, _punctuationOrSpaceGfmDel) - .replace(/punct/g, _punctuationGfmDel) + .replace(/notPunctSpace/g, _notPunctuationOrSpace) + .replace(/punctSpace/g, _punctuationOrSpace) + .replace(/punct/g, _punctuation) .getRegex(); const anyPunctuation = edit(/\\(punct)/, 'gu') diff --git a/test/specs/new/del_flanking.html b/test/specs/new/del_flanking.html index f097b733..1cfcec77 100644 --- a/test/specs/new/del_flanking.html +++ b/test/specs/new/del_flanking.html @@ -3,3 +3,5 @@

Between (~1.34) and (~5.4)

~ test~

~test ~

+

The mass of the Higgs boson is ~125 GeV, while the top quark is ~173 GeV

+

~~1 ~~2

diff --git a/test/specs/new/del_flanking.md b/test/specs/new/del_flanking.md index 9f93a3b3..6eeb2981 100644 --- a/test/specs/new/del_flanking.md +++ b/test/specs/new/del_flanking.md @@ -7,3 +7,7 @@ Between (~1.34) and (~5.4) ~ test~ ~test ~ + +The mass of the Higgs boson is ~125 GeV, while the top quark is **~173 GeV** + +~~1 **~~2** diff --git a/test/specs/new/del_strikethrough.html b/test/specs/new/del_strikethrough.html index 980134aa..416de2af 100644 --- a/test/specs/new/del_strikethrough.html +++ b/test/specs/new/del_strikethrough.html @@ -13,4 +13,8 @@ test

test~~

+

1 a2

+ +

1 a2

+
diff --git a/test/specs/new/del_strikethrough.md b/test/specs/new/del_strikethrough.md index f3d5bca0..814d5b8d 100644 --- a/test/specs/new/del_strikethrough.md +++ b/test/specs/new/del_strikethrough.md @@ -13,4 +13,8 @@ test~~ test~~ +~1 a~2 + +~~1 a~~2 + ~~~test~~~