Skip to content

Add abbreviation and escaped character round-trip support#159

Merged
dereuromark merged 7 commits intomasterfrom
feature/round-trip-edge-cases
Apr 1, 2026
Merged

Add abbreviation and escaped character round-trip support#159
dereuromark merged 7 commits intomasterfrom
feature/round-trip-edge-cases

Conversation

@dereuromark
Copy link
Copy Markdown
Contributor

Summary

  • Adds EscapedText node class to preserve escape sequences (\*, \_, etc.) during round-trips
  • Stores abbreviation definitions on Document and outputs them via <template data-djot-abbreviations> element
  • HtmlToDjot extracts abbreviations from template element and escaped chars from data-djot-escaped spans
  • Removes both from the "Round-Trip Limitations" section in documentation

Changes

  • src/Node/Inline/EscapedText.php - New node class for escaped punctuation
  • src/Node/Document.php - Added abbreviations property with getter/setter
  • src/NodeType.php - Added ESCAPED_TEXT constant
  • src/Parser/BlockParser.php - Store abbreviations on document after parsing
  • src/Parser/InlineParser.php - Create EscapedText nodes instead of text for escaped chars
  • src/Renderer/HtmlRenderer.php - Render abbreviation template and escaped text spans
  • src/Converter/HtmlToDjot.php - Extract abbreviations and escaped characters
  • tests/TestCase/RoundTripTest.php - Added 8 new tests
  • tests/TestCase/Parser/InlineParserTest.php - Updated to expect EscapedText nodes
  • docs/guide/converters.md - Updated round-trip documentation

- Create EscapedText node class for preserving escape sequences
- Store abbreviation definitions on Document for round-trip
- Add data-djot-escaped span wrapper in HtmlRenderer
- Add template element for abbreviation definitions
- Extract abbreviations and escaped chars in HtmlToDjot
- Add 8 new round-trip tests
- Update documentation
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 1, 2026

Codecov Report

❌ Patch coverage is 96.15385% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.80%. Comparing base (60e5532) to head (3157dd4).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/Node/Inline/EscapedText.php 71.42% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #159      +/-   ##
============================================
+ Coverage     93.78%   93.80%   +0.01%     
- Complexity     3007     3027      +20     
============================================
  Files            92       93       +1     
  Lines          7758     7809      +51     
============================================
+ Hits           7276     7325      +49     
- Misses          482      484       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dereuromark dereuromark merged commit 3a4e56f into master Apr 1, 2026
6 checks passed
@dereuromark dereuromark deleted the feature/round-trip-edge-cases branch April 1, 2026 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant