Commit 2d26bc8
fix(inline): use original run length in emphasis multiple-of-3 rule
CommonMark rules 9 and 10 require the multiple-of-3 delimiter test to use
the lengths of the original delimiter runs, not the lengths remaining after
a run has been partially consumed. mistune mutated _Delimiter.length as it
consumed markers and then reused that mutated value in the mod-3 test, so the
leftover of a partially consumed run (e.g. the ** left after *a* closes in
'*a***a*') could no longer match a later delimiter.
Track the original run length on _Delimiter and use it in
_can_match_emphasis_delimiters. Fixes cases such as '*a***a*' and
'*foo***bar*', which two CommonMark reference implementations
(markdown-it-py, commonmark.py) render as <em>a</em>*<em>a</em> and
<em>foo</em>*<em>bar</em>.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 90b1a73 commit 2d26bc8
2 files changed
Lines changed: 25 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
529 | 529 | | |
530 | 530 | | |
531 | 531 | | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
532 | 535 | | |
533 | 536 | | |
534 | 537 | | |
| |||
618 | 621 | | |
619 | 622 | | |
620 | 623 | | |
621 | | - | |
| 624 | + | |
622 | 625 | | |
623 | 626 | | |
624 | 627 | | |
| |||
733 | 736 | | |
734 | 737 | | |
735 | 738 | | |
736 | | - | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
737 | 745 | | |
738 | 746 | | |
739 | 747 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
57 | 72 | | |
58 | 73 | | |
59 | 74 | | |
| |||
0 commit comments