Fix qmd writer dropping trailing newline after implicit-figure shape (issue #180) - #189
Merged
Conversation
…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>
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
write_figure's implicit-figure branch delegated towrite_imageand returned directly.write_imageis an inline writer with no trailing newline, which violates the block-writer contract used bywrite_implandwrite_div(every block ends in\nso 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 onePara.Closes #180. Tracks bd-cpzp. Triage record on this branch under
claude-notes/issue-reports/180/.Test plan
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.cargo run --bin pampa -- -t qmdthen 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-testsgreen (Rust build + workspace nextest + trace-viewer).--skip-hub-testsbecausemainhas an unrelated hub-client vitest config failure (Cannot find package 'compression') that needs a separatenpm installpass.🤖 Generated with Claude Code