fix: let emphasis open after the other delimiter character (#4169)

This commit is contained in:
Shaurya Kesarwani
2026-11-09 15:35:38 -07:00
committed by GitHub
parent b81a00a2e3
commit 219492a64e
3 changed files with 18 additions and 2 deletions
+4 -2
View File
@@ -915,12 +915,14 @@ export class _Tokenizer<ParserOutput = string, RendererOutput = string> {
runStart--;
}
const runPrevChar = [...maskedSrc.slice(Math.max(0, runStart - 2), runStart)].at(-1) ?? '';
// The other delimiter character counts as punctuation here (`_**a*`)
// The other delimiter character counts as punctuation here (`_**a*`, `*_#_`)
const runPrevPunct = runPrevChar === '*' || runPrevChar === '_' || !!this.rules.inline.punctuation.exec(runPrevChar);
if (runStart < srcStart) {
prevChar = runPrevChar;
}
const prevPunct = runStart < srcStart ? runPrevPunct : !!this.rules.inline.punctuation.exec(prevChar);
const prevPunct = runStart < srcStart
? runPrevPunct
: prevChar === '*' || prevChar === '_' || !!this.rules.inline.punctuation.exec(prevChar);
// _ can't be between two alphanumerics. \p{L}\p{N} includes non-english alphabet/numbers as well
if (match[4] && prevChar.match(this.rules.other.unicodeAlphaNumeric)) return;
@@ -0,0 +1,5 @@
<p>*<em>#a</em></p>
<p>**<em>(a)</em></p>
<p>see *<em>[link]</em></p>
<p>*<strong>#</strong></p>
<p>_<em>#</em></p>
@@ -0,0 +1,9 @@
*_#a_
**_(a)_
see *_[link]_
*__#__
_*#*