fix: collapse adjacent quote-table spacers (#76)#77
Merged
Conversation
Adjacent ::: note blocks rendered as single-cell tables (bcecaf5) accumulated two empty spacer paragraphs between every pair — the prior table's after-spacer plus the next table's before-spacer — producing ~2 lines of unintended whitespace. Make the before-spacer collapse against an immediately preceding spacer paragraph using max(prev.SpaceAfter, next.SpaceBefore), mirroring CSS margin-collapse semantics. Applied to both AddQuoteAsTable and AddTable so consecutive plain tables benefit from the same fix.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #77 +/- ##
==========================================
- Coverage 89.17% 88.90% -0.27%
==========================================
Files 28 28
Lines 1608 1623 +15
Branches 206 215 +9
==========================================
+ Hits 1434 1443 +9
Misses 128 128
- Partials 46 52 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This was referenced May 5, 2026
Closed
forest6511
added a commit
that referenced
this pull request
May 5, 2026
#78) (#79) #76 / #77 only collapsed against empty spacer paragraphs, so the visible blank-line regression remained at the heading-single-paragraph → quote-table boundary (and at any text → quote-table boundary where the preceding paragraph already supplied SpaceAfter). Generalise AddCollapsingBeforeSpacer to fold the requested before-spacing into the previous paragraph's SpacingBetweenLines.After whenever that After is positive, regardless of whether the paragraph contains runs. This matches CSS-like margin-collapse semantics and uniformly covers the table-table, heading-table, and text-table boundaries. The IsBodySpacerParagraph helper becomes unnecessary and is removed.
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
::: noteblocks rendered as single-cell tables (since bcecaf5) accumulated two spacer paragraphs between every pair, producing ~2 lines of visible whitespace.AddCollapsingBeforeSpacernow collapses each block's before-spacer against an immediately preceding empty spacer paragraph, keepingmax(prev.SpaceAfter, next.SpaceBefore)(CSS margin-collapse semantics).AddQuoteAsTableandAddTable, so the same regression in the rare adjacent-tables case is also fixed.Approach
Issue #76 listed three options. This PR is Option B (margin-collapse): more correct than the minimal Option A and a tiny amount more code (one helper + one predicate). When two adjacent quote-tables share the same
SpaceBefore/SpaceAfter, the collapsed gap equals one spacer paragraph — matching thebcecaf5-prior paragraph rendering.The detection (
IsBodySpacerParagraph) treats any empty body-level paragraph withBefore="0"and a non-emptyAfteras collapsible. Heading after-spacers match this shape too, which is intentional — collapsing against a heading's after-spacer withmax()never shrinks the gap, only avoids stacking.Test plan
dotnet test(323 / 323 passing, 0 warnings introduced)AddQuote_AdjacentTableQuotes_ShouldCollapseSpacersToSingleParagraph— three back-to-back quote-tables, asserts exactly one body element between every pair.AddQuote_AdjacentTableQuotes_ShouldKeepLargerCollapsedSpacing— differingSpaceBefore/SpaceAftercollapse tomax().AddTable_AdjacentTables_ShouldCollapseSpacersToSingleParagraph— same rule for plain Markdown tables.forest6511/rust-textbook-advancedand remove the Python post-processing workaround — no longer needed.