Skip to content

Plain text: a captioned figure keeps its caption on its own line - #271

Merged
dereuromark merged 1 commit into
masterfrom
fix/plain-text-figure-caption
Aug 15, 2026
Merged

Plain text: a captioned figure keeps its caption on its own line#271
dereuromark merged 1 commit into
masterfrom
fix/plain-text-figure-caption

Conversation

@dereuromark

Copy link
Copy Markdown
Contributor

Follow-up to #270, but a standalone bug that predates it: found while checking how a composite figure degrades to plain text, and reproducible on master with an ordinary captioned image.

PlainTextRenderer::renderNode() has no arm for Figure and none for Caption, so both fall through to default => $this->renderChildren($node).

Input:

![a](a.png)
^ Panel caption

Plain text on master:

aPanel caption

The alt text is glued straight onto the caption, with no separator and no trailing blank line, so nothing marks where the figure ends. Every other block in this renderer terminates with a blank line, and AnsiRenderer has had renderFigure() and renderCaption() all along - plain text was the only target missing them.

After:

a
Panel caption

Shape

renderFigure() renders each child on its own line, caption last, and terminates the block with one blank line like every neighbouring block method. renderCaption() returns the trimmed caption text with no terminator, so the caller owns the separators; the standalone arm only exists for a caption that somehow appears outside a figure.

The table path is untouched

A table caption never dispatches through renderNode() - renderTable() reads it off the node with getCaption() - so the new Caption arm cannot reach it. The existing table-caption test pins that output unchanged, which is what makes the claim checkable rather than merely stated.

Interaction with the composite-figure branch

#270 has a degradation test that asserts the current glued plain-text string. Whichever of the two lands second needs that assertion updated to the fixed output; #270 is a draft, so the simplest order is this one first and then a rebase there.

PlainTextRenderer had no arm for Figure and none for Caption, so both
fell through to the default child-concatenation. A captioned image
rendered as `aPanel caption`: the alt text glued straight onto the
caption, no separator, no trailing blank line, and nothing to tell a
reader where the figure ended.

Every other block in this renderer terminates with a blank line, and the
ANSI renderer has carried a figure and caption arm all along. Plain text
now matches: each child on its own line, the caption last, one blank
line after the figure.

The table path is untouched. Its caption goes through renderTable(),
which reads the caption off the node rather than dispatching it, so the
new Caption arm cannot reach it; the existing table-caption test pins
that output unchanged.
@codecov

codecov Bot commented Aug 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.75000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 92.41%. Comparing base (0379f22) to head (035a729).

Files with missing lines Patch % Lines
src/Renderer/PlainTextRenderer.php 93.75% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master     #271   +/-   ##
=========================================
  Coverage     92.41%   92.41%           
- Complexity     3674     3682    +8     
=========================================
  Files           109      109           
  Lines         10424    10440   +16     
=========================================
+ Hits           9633     9648   +15     
- Misses          791      792    +1     

☔ View full report in Codecov by Harness.
📢 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 d1aab1a into master Aug 15, 2026
6 checks passed
@dereuromark
dereuromark deleted the fix/plain-text-figure-caption branch August 15, 2026 11:39
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