Skip to content
7 changes: 7 additions & 0 deletions src/Tokenizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,13 @@ export class _Tokenizer<ParserOutput = string, RendererOutput = string> {

// Create del token - only single ~ or double ~~ supported
const text = raw.slice(lLength, -lLength);

// For single ~, skip if closing ~ is followed by an alphanumeric character.
// Prevents e.g. `~125 GeV, while the top quark is **~173 GeV**` from matching as strikethrough,
// since the closing ~ fails GFM right-flanking delimiter rules.
// See https://github.github.com/gfm/#emphasis-and-strong-emphasis
if (lLength === 1 && raw.length < src.length && /[0-9a-zA-Z]/.test(src[raw.length])) continue;
Comment thread
diadorer marked this conversation as resolved.
Resolved

return {
type: 'del',
raw,
Expand Down
1 change: 1 addition & 0 deletions test/specs/new/del_flanking.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
<p>Between (~1.34) and (~5.4)</p>
<p>~ test~</p>
<p>~test ~</p>
<p>The mass of the Higgs boson is ~125 GeV, while the top quark is <strong>~173 GeV</strong></p>
2 changes: 2 additions & 0 deletions test/specs/new/del_flanking.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,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**