@@ -278,6 +278,11 @@ const _punctuationGfmStrongEm = /(?!~)[\p{P}\p{S}]/u;
278278const _punctuationOrSpaceGfmStrongEm = / (? ! ~ ) [ \s \p{ P} \p{ S} ] / u;
279279const _notPunctuationOrSpaceGfmStrongEm = / (?: [ ^ \s \p{ P} \p{ S} ] | ~ ) / u;
280280
281+ // GFM allows * and _ inside strikethrough
282+ const _punctuationGfmDel = / (? ! [ * _ ] ) [ \p{ P} \p{ S} ] / u;
283+ const _punctuationOrSpaceGfmDel = / (? ! [ * _ ] ) [ \s \p{ P} \p{ S} ] / u;
284+ const _notPunctuationOrSpaceGfmDel = / (?: [ ^ \s \p{ P} \p{ S} ] | [ * _ ] ) / u;
285+
281286// sequences em should skip over [title](link), `code`, <html>
282287const blockSkip = edit ( / l i n k | p r e c o d e - c o d e | h t m l / , 'g' )
283288 . replace ( 'link' , / \[ (?: [ ^ \[ \] ` ] | (?< a > ` + ) [ ^ ` ] + \k<a > (? ! ` ) ) * ?\] \( (?: \\ [ \s \S ] | [ ^ \\ \( \) ] | \( (?: \\ [ \s \S ] | [ ^ \\ \( \) ] ) * \) ) * \) / )
@@ -332,6 +337,27 @@ const emStrongRDelimUnd = edit(
332337 . replace ( / p u n c t / g, _punctuation )
333338 . getRegex ( ) ;
334339
340+ // Tilde left delimiter for strikethrough (similar to emStrongLDelim for asterisk)
341+ const delLDelim = edit ( / ^ ~ ~ ? (?: ( (? ! ~ ) p u n c t ) | [ ^ \s ~ ] ) / , 'u' )
342+ . replace ( / p u n c t / g, _punctuationGfmDel )
343+ . getRegex ( ) ;
344+
345+ // Tilde delimiter patterns for strikethrough (similar to asterisk)
346+ const delRDelimCore =
347+ '^[^~]+(?=[^~])' // Consume to delim
348+ + '|(?!~)punct(~~?)(?=[\\s]|$)' // (1) #~~ can only be a Right Delimiter
349+ + '|notPunctSpace(~~?)(?!~)(?=punctSpace|$)' // (2) a~~#, a~~ can only be a Right Delimiter
350+ + '|(?!~)punctSpace(~~?)(?=notPunctSpace)' // (3) #~~a, ~~a can only be Left Delimiter
351+ + '|[\\s](~~?)(?!~)(?=punct)' // (4) ~~# can only be Left Delimiter
352+ + '|(?!~)punct(~~?)(?!~)(?=punct)' // (5) #~~# can be either Left or Right Delimiter
353+ + '|notPunctSpace(~~?)(?=notPunctSpace)' ; // (6) a~~a can be either Left or Right Delimiter
354+
355+ const delRDelim = edit ( delRDelimCore , 'gu' )
356+ . replace ( / n o t P u n c t S p a c e / g, _notPunctuationOrSpaceGfmDel )
357+ . replace ( / p u n c t S p a c e / g, _punctuationOrSpaceGfmDel )
358+ . replace ( / p u n c t / g, _punctuationGfmDel )
359+ . getRegex ( ) ;
360+
335361const anyPunctuation = edit ( / \\ ( p u n c t ) / , 'gu' )
336362 . replace ( / p u n c t / g, _punctuation )
337363 . getRegex ( ) ;
@@ -389,6 +415,8 @@ const inlineNormal = {
389415 br,
390416 code : inlineCode ,
391417 del : noopTest ,
418+ delLDelim : noopTest ,
419+ delRDelim : noopTest ,
392420 emStrongLDelim,
393421 emStrongRDelimAst,
394422 emStrongRDelimUnd,
@@ -427,6 +455,8 @@ const inlineGfm: Record<InlineKeys, RegExp> = {
427455 ...inlineNormal ,
428456 emStrongRDelimAst : emStrongRDelimAstGfm ,
429457 emStrongLDelim : emStrongLDelimGfm ,
458+ delLDelim,
459+ delRDelim,
430460 url : edit ( / ^ ( (?: p r o t o c o l ) : \/ \/ | w w w \. ) (?: [ a - z A - Z 0 - 9 \- ] + \. ? ) + [ ^ \s < ] * | ^ e m a i l / )
431461 . replace ( 'protocol' , _caseInsensitiveProtocol )
432462 . replace ( 'email' , / [ A - Z a - z 0 - 9 . _ + - ] + ( @ ) [ a - z A - Z 0 - 9 - _ ] + (?: \. [ a - z A - Z 0 - 9 - _ ] * [ a - z A - Z 0 - 9 ] ) + (? ! [ - _ ] ) / )
0 commit comments