Repository navigation
🐛 fix(markdown): write non-ASCII options as given - #2239
Merged
gaborbernat merged 3 commits intoNov 16, 2026
Merged
Conversation
Option strings arrive as UTF-8, but the list bullet was taken one byte at a time and each byte was written as its own character, so a bullet of "•" came out as "â" followed by a stray byte. The emphasis checks compared the first byte of a configured wrapper with the output character before it, so two wrappers that share a lead byte were treated as one delimiter and fell back to raw HTML. Bullets now cycle by code point, and the wrapper checks compare code points. PlainText's table cell separator and default image alt decode their UTF-8 the same way. Fixes tox-dev#2238
Merging this PR will not alter performance
Comparing Footnotes
|
This was referenced Nov 16, 2026
gaborbernat
added a commit
that referenced
this pull request
Nov 16, 2026
Markdown export of a list whose bullet is the default `-` got slower after #2239. The bullet is now found by walking the configured bullet string for every list item, and that walk costs more than the bullet itself when the string is one character long. This change returns one-character bullets directly, so list-heavy exports are back to their earlier cost. Multi-character bullet strings keep the walk. ### Performance Callgrind instructions per call on the Markdown list row, merge commit d5619d9 against this branch: 610,824 before, 607,584 after (−0.53%). The parent of that merge measured 608,034, so the list row is now below its pre-merge cost. The emphasis row moved from 408,516 to 408,514. The untouched rewrite control row moved from 3,922 to 3,857. Fixes #2337.
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.
Non-ASCII list bullets came out as mojibake.
Markdown(lists=Markdown.Lists(bullets="•"))rendered each item asâ awith a stray byte on the continuation line, so Markdown exported with a typographic bullet was unreadable. Once this merges, configured bullets, emphasis wrappers and PlainText's cell separator and default image alt are written as given. Fixes #2238.The bullet was written one byte at a time
The bullet was read by byte index into the configured UTF-8 string and written as one code point per byte, so a three-byte bullet became three characters. The same byte-indexed bullet was used for every nested list. Bullets now step through the configured string by code point, and the list marker is written as the code point it names.
The emphasis checks compared bytes with characters
The output is held as code points, but the check that decides whether an emphasis wrapper needs its raw HTML fallback compared the first byte of the wrapper with the output character. Two wrappers that share a lead byte, such as
«and», were then treated as one delimiter and fell back to<em>. The wrapper checks now compare the first code point and count code points, and the same decoding covers PlainText'stable_cell_separatoranddefault_image_alt.Behavior changes
ASCII configuration produces the same output as before. A non-ASCII wrapper that used to fall back to raw HTML because of a shared lead byte now keeps its own delimiter. No new errors are raised.