Skip to content

🐛 fix(markdown): keep edge spaces in inline code - #1238

Merged
gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:fix/markdown-code-span-spaces
Oct 8, 2026
Merged

gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:fix/markdown-code-span-spaces

Conversation

@gaborbernat

Copy link
Copy Markdown
Member

to_markdown wrote inline code that starts and ends with a space as written. <p>x<code> a </code>y</p> became x` a `y, and a reader strips one space from each end of such content (CommonMark 6.1), so it read back as xay in one word.

Content that both starts and ends with a space, and is not all spaces, now gets one more space on each side, as content edged by a backtick already did. The example becomes x` a `y.

markdownify 1.2.3 writes x `a` y, moving the spaces outside the code, and html2text 2025.4.15 writes x` a `y, which loses them.

@gaborbernat gaborbernat added the bug Something isn't working label Oct 8, 2026
A reader strips one space from each end of code span content that starts and
ends with one (CommonMark 6.1), so <code> a </code> between two words read
back as "a" and fused the words. Such content now gets one more space on each
side, as content edged by a backtick already did.
@gaborbernat
gaborbernat force-pushed the fix/markdown-code-span-spaces branch from 854fdbb to 7d4e4e0 Compare October 8, 2026 14:47
@codspeed

codspeed Bot commented Oct 8, 2026

Copy link
Copy Markdown

Merging this PR will regress 1 benchmark

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
❌ 1 regressed benchmark
✅ 579 untouched benchmarks
⏩ 32 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ test_feature[prune-shared-single] 89.1 µs 96.7 µs -7.83%
⚡ test_feature[shadow-slot-comments] 137.9 µs 110.1 µs +25.23%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing gaborbernat:fix/markdown-code-span-spaces (7d4e4e0) with main (af31f20)

Open in CodSpeed

Footnotes

  1. 32 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@gaborbernat
gaborbernat merged commit ddf0f1f into tox-dev:main Oct 8, 2026
35 of 63 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant