Fix renderer content loss in non-HTML renderers (markdown/plain/ansi)#246
Merged
Conversation
Content vanished in the markdown / plain / ansi renderers (HTML was fine): - EscapedText (e.g. an escaped literal like a backslash-star) was dropped in all three: the node is not a Text subclass, so it fell through to renderChildren() and produced nothing. Added an explicit arm in each renderer. Markdown keeps the leading backslash so the literal stays literal when re-parsed; plain/ansi emit the raw content. - MarkdownRenderer had no Figure / Caption arms, so a captioned image glued the caption to the image; and no Abbreviation arm, so the title was lost. Added renderFigure (caption on its own block), renderCaption, and renderAbbreviation (inline abbr HTML, mirroring how sub/sup fall back to inline HTML). - A Div's title attribute (Djot attribute syntax title="...") was dropped in all three non-HTML renderers' renderDiv. Preserve it as a leading bold/plain line. Ported from carve-php commit 217b72f.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #246 +/- ##
============================================
+ Coverage 92.06% 92.10% +0.04%
- Complexity 3571 3590 +19
============================================
Files 107 107
Lines 10118 10152 +34
============================================
+ Hits 9315 9351 +36
+ Misses 803 801 -2 ☔ View full report in Codecov by Harness. 🚀 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.
Problem
The non-HTML renderers (markdown / plain / ansi) silently dropped content that the HTML renderer rendered correctly:
Textsubclass, so it fell through torenderChildren()and produced nothing.Figure/Captionarms, so a captioned image glued the caption directly onto the image (e.g.i.png)Cap), and noAbbreviationarm, so the abbreviation title was lost entirely.renderDiv.Fix
EscapedTextarm in each renderer. Markdown keeps the leading backslash so the literal stays literal when re-parsed as Markdown; plain/ansi emit the raw content.renderFigure(caption on its own block, with a blank line before the caption so it is not swallowed as a lazy continuation),renderCaption, andrenderAbbreviation(inline abbr HTML, mirroring how subscript/superscript already fall back to inline HTML) to MarkdownRenderer.Ported from carve-php commit 217b72f. The two libraries share renderer architecture; the namespaces and node APIs differ (
Carve\vsDjot\). The Div-title test uses Djot's native attribute syntaxtitle="..."(which genuinely populates the Div title attribute) rather than carve's admonition-specific syntax.Tests
Added
tests/TestCase/Renderer/RendererContentLossTest.phpcovering escaped text, abbreviation title, figure/caption separation, and Div title preservation across the affected renderers. Each assertion fails on the unpatched renderers and passes with the fix.