Repository navigation
Keep emphasis nested directly in emphasis when re-rendering Markdown - #312
Merged
frostming merged 1 commit intoNov 11, 2026
Merged
Conversation
|
🛡️ Human Attestation required. A human needs to confirm this PR once before it can merge. Attest this PR — sign in with GitHub, pass the challenge, and confirm one of the statements. |
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.
MarkdownRendererwrites every emphasis with*, so when emphasis is the only content of another emphasis, the delimiters of both join into one run and the nesting changes. The common bold italic**_foo_**is one case:The same happens with
__*foo*__, and*_foo_*(spec example 460) and_*foo*_(462) come back as**foo**, which is strong emphasis.When the only child of an emphasis or strong emphasis is an emphasis, that inner emphasis is now written with
_(or*if the outer one uses_), so**_foo_**stays**_foo_**. Its_always has the outer*next to it, so the rules for_inside words don't apply. Other nesting is unchanged:***foo***, emphasis around strong emphasis, already gives the same HTML, and so doesfoo***bar***baz.Added
test_markdown_renderer_nested_emphasis; 5 of its 7 cases fail on master, and the last two check that***foo***andfoo***bar***bazare unchanged. Across the CommonMark spec examples, the number whose re-rendered Markdown gives different HTML goes from 17 to 15.pytest tests, black, isort and flake8 pass, and mypy reports the same 5 errors as on master.Used Claude (Opus) to help find and patch this; I reviewed and tested the change