Separate adjacent same-delimiter inline runs in HtmlToDjot + doc fixes#205
Merged
Conversation
Two adjacent inline elements sharing a Djot delimiter merged into one
malformed token on the round-trip: `<em>a</em><em>b</em>` serialized to
`_a__b_` and re-parsed as `<em>a_</em>b_`. The same happened for strong,
sub, super and code spans.
Insert an empty attribute group `{}` between two pieces when the left
ends and the right begins with the same delimiter (`_`, `*`, `~`, `^` or
backtick). `{}` renders to nothing, so the value is unchanged while the
two runs stay separate. A trailing escaped delimiter (`\_`) is literal
text and is left alone.
Extend the round-trip property test with an adjacency sweep over em,
strong, sub, sup, code, del, mark and ins.
Also fix two documentation overclaims in the converter guide: round-trip
mode is lossless for supported constructs (not "perfect"), and code-block
fence length is normalized rather than preserved.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #205 +/- ##
============================================
- Coverage 91.80% 91.79% -0.02%
- Complexity 3450 3457 +7
============================================
Files 104 104
Lines 9786 9798 +12
============================================
+ Hits 8984 8994 +10
- Misses 802 804 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
dereuromark
added a commit
that referenced
this pull request
Jun 2, 2026
…206) The same-delimiter separator added in #205 only ran through processChildren(), so it covered paragraphs but not the two other places that buffer inline output by hand: processBlock() (bare top-level inline) and processList() (list-item content). There `<em>a</em><em>b</em>` still serialized to `_a__b_` and round-tripped to `<em>a_</em>b_`. Extract the join into a shared appendInline() helper and use it on all three concatenation paths, so adjacency is handled the same everywhere. Extend the property test with bare and list contexts across em, strong, sub, sup and code.
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.
Follow-up to the HtmlToDjot round-trip work (#202, #203, #204).
Problem (G2)
Two adjacent inline elements that share a Djot delimiter merged into a single malformed token on the round-trip:
Same for
<sub>and<sup>. Brace-delimited inlines (<del>,<mark>,<ins>) and mixed delimiters (<em>then<strong>) were already fine.Fix
When concatenating inline children, insert an empty attribute group
{}between two pieces where the left ends and the right begins with the same delimiter (_,*,~,^, or backtick).{}renders to nothing, so the content is unchanged while the two runs stay distinct:A trailing escaped delimiter (
\_, produced for literal text) is recognized and left alone, so genuine literal characters are not affected.The round-trip property test gains an adjacency sweep over
em,strong,sub,sup,code,del,mark,ins(pairs and triples), plus the mixed-delimiter and space-separated cases as regression guards.Docs (G3)
Fixes two overclaims in the converter guide: