Pad code-span content symmetrically in HtmlToDjot#203
Merged
Conversation
When inline code content begins or ends with a backtick, HtmlToDjot added a separating space to only that end. Djot strips a leading and trailing space from a code span only when both ends have one (and the span is not all spaces), so a lone pad space was kept as content: a `<code>` of `` `a `` round-tripped to `` `a `` with an extra leading space. Pad both ends when separation is needed, so the strip rule restores the exact content. Content that already starts or ends with a real space is unaffected (no extra padding is added there).
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #203 +/- ##
============================================
- Coverage 91.80% 91.80% -0.01%
+ Complexity 3452 3450 -2
============================================
Files 104 104
Lines 9788 9786 -2
============================================
- Hits 8986 8984 -2
Misses 802 802 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This was referenced Jun 2, 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.
Problem
HtmlToDjotcorrupted inline code whose content begins or ends with a backtick. It added the fence-separating space to only the affected end:Djot removes a single leading and trailing space from a code span only when both ends have one and the span is not all spaces. A lone pad space therefore survives as content and changes the value on the next parse.
Fix
When the content needs separating from the fence (it starts or ends with a backtick and not already a space), pad both ends. The strip rule then removes both and restores the exact content:
Content that already starts or ends with a real space is untouched (the existing space already separates the fence, so no extra padding is added and the significant space is preserved). All-space content and the symmetric case (
`a`) were already correct and stay correct.