Add extended round-trip support for links and inline elements#157
Merged
dereuromark merged 2 commits intomasterfrom Apr 1, 2026
Merged
Add extended round-trip support for links and inline elements#157dereuromark merged 2 commits intomasterfrom
dereuromark merged 2 commits intomasterfrom
Conversation
- Reference links: Store reference label on Link/Image nodes and emit data-djot-ref attribute. HtmlToDjot reconstructs [text][ref] syntax and outputs reference definitions at document end. - Autolinks: Mark autolinks with isAutolink flag and emit data-djot-autolink attribute. HtmlToDjot outputs <url> syntax. - Custom heading IDs: Emit data-djot-explicit-id on sections with explicit IDs. HtmlToDjot combines section ID with heading attributes. - Mentions: HtmlToDjot detects data-username attribute to restore @username syntax. - Tables: Changed separator format to compact (no padding spaces), allow 2-dash minimum width. - Inline code: Fixed spacing for code containing backticks. - Documentation: Updated round-trip section with new features, extension support, and limitations. - Tests: Added 56 round-trip tests covering all new features.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #157 +/- ##
============================================
- Coverage 93.77% 93.74% -0.03%
- Complexity 2874 2980 +106
============================================
Files 92 92
Lines 7466 7691 +225
============================================
+ Hits 7001 7210 +209
- Misses 465 481 +16 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Add data-djot-footnote-label attribute to footnote references and definitions for preserving [^label] syntax during round-trips - Update HtmlToDjot to detect and process doc-endnotes section, extracting footnote definitions with backlinks removed - Add data-djot-admonition-type attribute to AdmonitionExtension for preserving ::: type div syntax during round-trips - Update HtmlToDjot to detect and process admonition divs and collapsible details elements, reconstructing original syntax - Add 13 new round-trip tests for footnotes and admonitions - Update documentation with new round-trip features
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.
Summary
This PR significantly extends the round-trip (Djot → HTML → Djot) capabilities:
[text][ref]and[text][]syntax now round-trips viadata-djot-refattribute<url>and<email>syntax now round-trips viadata-djot-autolinkattribute{#custom-id}on headings now round-trips viadata-djot-explicit-idattribute@usernamesyntax round-trips via existingdata-usernameattribute detection[^label]and[^label]: contentsyntax now round-trips viadata-djot-footnote-labelattribute::: typediv syntax with AdmonitionExtension now round-trips viadata-djot-admonition-*attributesChanges
New round-trip features:
[text][ref]syntax and outputs reference definitions at document endisAutolinkflag, HtmlToDjot outputs<url>syntax[^label]references and[^label]: contentdefinitions viadata-djot-footnote-labelattributes::: typediv syntax including custom titles and collapsible state viadata-djot-admonition-*attributesBug fixes:
Documentation:
Testing