mirror of
https://github.com/markedjs/marked.git
synced 2026-11-30 16:48:05 +01:00
fix: let a mid-run opener close against a delimiter that can also open (#4203)
This commit is contained in:
+8
-7
@@ -1033,14 +1033,15 @@ export class _Tokenizer<ParserOutput = string, RendererOutput = string> {
|
||||
delimTotal += rLength;
|
||||
continue;
|
||||
} else if (match[5] || match[6] || openerCanClose) { // either Left or Right Delim
|
||||
if (midRun && (match[5] || match[6])) {
|
||||
// A mid-run opener cannot close against an ambiguous delimiter that
|
||||
// can also open; that delimiter opens its own emphasis span instead.
|
||||
break;
|
||||
}
|
||||
if (runLength % 3 && !((runLength + rLength) % 3)) {
|
||||
if (runLength % 3 && !((runLength + rLength) % 3)) { // CommonMark Emphasis Rules 9-10
|
||||
if (midRun && (match[5] || match[6])) {
|
||||
// A delimiter that can also open and cannot close this run
|
||||
// opens its own span; a later closer pairs with it, not with a
|
||||
// mid-run opener (`**a*a*` must be `**a<em>a</em>`).
|
||||
break;
|
||||
}
|
||||
midDelimTotal += rLength;
|
||||
continue; // CommonMark Emphasis Rules 9-10
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<p>**<em>a</em>a</p>
|
||||
|
||||
<p>*<strong>a</strong>a</p>
|
||||
|
||||
<p>*<em><em>a</em>a</em></p>
|
||||
|
||||
<p>***<em>a</em>a</p>
|
||||
|
||||
<p>-**<em>[h]</em>"a</p>
|
||||
|
||||
<p>**a<em>a</em></p>
|
||||
@@ -0,0 +1,11 @@
|
||||
***a*a
|
||||
|
||||
***a**a
|
||||
|
||||
***a*a*
|
||||
|
||||
****a*a
|
||||
|
||||
-***[h]*"a
|
||||
|
||||
**a*a*
|
||||
Reference in New Issue
Block a user