Escape leading colon markers in HtmlToDjot + roundtrip property net#204
Merged
Conversation
A paragraph of external HTML that began with a colon was re-parsed as a block on the next Djot parse: `: x` opened a definition list and `::: x` opened a fenced div, the latter capturing the text into a class name and dropping the content entirely. Add a leading colon to the block-marker escaping alongside the existing `-`, `+`, `#`, `>` and ordered-list handling, so `: x` and `::: x` stay literal text. Add a generated round-trip property test that sweeps Djot-significant leading tokens and inline markers across paragraph and inline-wrapped contexts, asserting the block structure and text are preserved. This net is what surfaced the colon gap and guards the whole class of "a literal marker silently became a block" regressions.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #204 +/- ##
=========================================
Coverage 91.80% 91.80%
Complexity 3450 3450
=========================================
Files 104 104
Lines 9786 9786
=========================================
Hits 8984 8984
Misses 802 802 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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 escaping work (#202, #203).
Problem (G1)
A paragraph of external HTML beginning with a colon was re-parsed as a different block on the next Djot parse:
The
:::case is the worst: the content is captured into the div class name and the text is lost.This is the same class as the leading
-,#,>and1.markers already handled;escapeLeadingBlockMarkersimply did not cover:.Fix
Add a leading colon to the block-marker escaping. Escaping the first colon neutralizes both a definition-list item (
: term) and a fenced div (::: name), so the text stays literal:\: just text,\::: not a div.Property net (G4)
Adds a generated round-trip property test that, for externally-authored HTML, sweeps Djot-significant leading tokens (
-+*#>::::1.1)---~~~```|...) and inline markers across paragraph and inline-wrapped (<span>) contexts, asserting::::case is caught).This sweep is what surfaced the colon gap, and it guards the whole "a literal marker silently became a block" class going forward instead of one example at a time. It also re-covers the markers fixed in #202.