Skip to content

Fix emphasis multiple-of-3 rule mis-rendering (e.g. *foo***bar*)#458

Merged
lepture merged 1 commit into
lepture:mainfrom
greymoth-jp:fix/emphasis-mod3-original-length
Jun 26, 2026
Merged

Fix emphasis multiple-of-3 rule mis-rendering (e.g. *foo***bar*)#458
lepture merged 1 commit into
lepture:mainfrom
greymoth-jp:fix/emphasis-mod3-original-length

Conversation

@greymoth-jp

Copy link
Copy Markdown
Contributor

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.

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

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.02%. Comparing base (90b1a73) to head (2d26bc8).

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           
Flag Coverage Δ
unittests 90.99% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lepture lepture merged commit fc15c87 into lepture:main Jun 26, 2026
27 checks passed
@lepture

lepture commented Jun 26, 2026

Copy link
Copy Markdown
Owner

Thanks

@sonarqubecloud

Copy link
Copy Markdown

lepture added a commit to lepture/wenmode that referenced this pull request Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants