Skip to content

Fix qmd writer dropping trailing newline after implicit-figure shape (issue #180) - #189

Merged
cscheid merged 2 commits into
mainfrom
bugfix/issue-180
May 12, 2026
Merged

Fix qmd writer dropping trailing newline after implicit-figure shape (issue #180)#189
cscheid merged 2 commits into
mainfrom
bugfix/issue-180

Conversation

@cscheid

@cscheid cscheid commented May 12, 2026

Copy link
Copy Markdown
Member

Summary

  • write_figure's implicit-figure branch delegated to write_image and returned directly. write_image is an inline writer with no trailing newline, which violates the block-writer contract used by write_impl and write_div (every block ends in \n so the inter-block separator becomes a blank line). When such a Figure was followed by any other block — top-level or as a Div child — the separator collapsed and the re-parser merged the two blocks into one Para.
  • Append the missing newline in the implicit-figure branch.
  • Add three roundtrip regression fixtures covering both reports in the issue plus an extra Figure→Figure case.

Closes #180. Tracks bd-cpzp. Triage record on this branch under claude-notes/issue-reports/180/.

Test plan

  • Three new fixtures under crates/pampa/tests/roundtrip_tests/qmd-json-qmd/ (figure_implicit_then_para, figure_implicit_then_figure, layout_div_subfigures) fail before the fix, pass after.
  • End-to-end verification via cargo run --bin pampa -- -t qmd then re-parse on both original repros from the issue body and the comment — both produce blank-line-separated output that round-trips to the original AST.
  • cargo xtask verify --skip-hub-build --skip-hub-tests green (Rust build + workspace nextest + trace-viewer). --skip-hub-tests because main has an unrelated hub-client vitest config failure (Cannot find package 'compression') that needs a separate npm install pass.

🤖 Generated with Claude Code

cscheid and others added 2 commits May 12, 2026 13:39
…igure shape (bd-cpzp)

Both reports in the issue (top-level Figure+Para collapse; layout/subfigure
Div children collapse) share one root cause: write_figure's implicit-figure
branch (crates/pampa/src/writers/qmd.rs:759) returns directly from
write_image without emitting the trailing '\n' the block-writer contract
requires. The inter-block separator then collapses to a single newline and
the re-parser merges the two blocks into one Para.

Triage record: claude-notes/issue-reports/180/triage.md
Fixtures: repro-figure-para.qmd, repro-layout-div.qmd,
          repro-figure-figure.qmd, repro-para-figure-OK.qmd (counter-example)
Follow-up: bd-cpzp (fix scope + TDD plan in the triage doc)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…(issue #180, bd-cpzp)

write_figure's implicit-figure branch delegated to write_image and returned
directly, but write_image is an inline writer with no trailing newline. The
block-writer contract — every block ends with '\n' so the inter-block
separator emitted by write_impl / write_div produces a blank line — was
violated, so any block that followed an implicit Figure (top-level or as a
Div child) got glued onto it and the re-parser merged the two blocks into
one Para. Affects every layout/subfigure div in the docs corpus.

Append the missing newline and add three roundtrip regression fixtures
covering both reports in the issue.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@cscheid
cscheid merged commit dff1110 into main May 12, 2026
4 checks passed
@cscheid
cscheid deleted the bugfix/issue-180 branch May 12, 2026 19:17
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.

qmd writer merges a Figure and the following Paragraph into a single block

1 participant