Fix emphasis multiple-of-3 rule mis-rendering (e.g. *foo***bar*)#458
Merged
lepture merged 1 commit intoJun 26, 2026
Merged
Conversation
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>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #458 +/- ##
=======================================
Coverage 91.01% 91.02%
=======================================
Files 34 34
Lines 3395 3398 +3
Branches 670 670
=======================================
+ Hits 3090 3093 +3
Misses 184 184
Partials 121 121
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Owner
|
Thanks |
|
lepture
added a commit
to lepture/wenmode
that referenced
this pull request
Jun 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



The emphasis "multiple of 3" rule misuses the remaining delimiter run length, so
*foo***bar*renders incorrectly. This is a regression from the new inline engine (commit 5de41fb). Triangulated against markdown-it-py and commonmark.py; 738 tests pass and a differential fuzz drops from 26 mismatches to 0.