fix: collapse quote-table before-spacer against preceding paragraph (#78)#79
Merged
Merged
Conversation
#78) #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.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #79 +/- ##
==========================================
+ Coverage 88.90% 89.07% +0.16%
==========================================
Files 28 28
Lines 1623 1620 -3
Branches 215 213 -2
==========================================
Hits 1443 1443
Misses 128 128
+ Partials 52 49 -3 ☔ View full report in Codecov by Sentry. 🚀 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.
Summary
IsBodySpacerParagraphrequired no runs). That left a visible blank line whenever the preceding body element was anH2/H3rendered viaAddHeadingSingleParagraph(the default path for headings withoutBorderExtent="text"), or a regular text paragraph that already suppliedSpaceAfter.AddCollapsingBeforeSpacer: fold the requested before-spacing into the previous paragraph'sSpacingBetweenLines.Afterwhenever thatAfteris positive, regardless of whether the paragraph contains runs. CSS-like margin-collapse, applied uniformly to table-table, heading-table, and text-table boundaries.IsBodySpacerParagraphbecomes unnecessary and is removed.Why this is safe
When the previous paragraph already has
After > 0, the new logic only ever grows that gap (max(existing, desired)). It never shrinks an existing gap and never reaches into paragraphs that don't carry an explicit trailing gap. Heading after-spacers, table/quote after-spacers, and explicit body-paragraphSpaceAfterare all handled the same way.When the previous paragraph has no
SpacingBetweenLinesorAfter == 0, behaviour is unchanged: a fresh spacer paragraph is appended.Test plan
After > 0).AddQuote_AfterHeading_ShouldCollapseAgainstHeadingSpaceAfter— headingSpaceAfter=280+ quoteSpaceBefore=160→ no spacer between, heading After stays 280.AddQuote_AfterHeading_ShouldGrowHeadingSpaceAfterWhenQuoteWantsLargerGap— headingSpaceAfter=100+ quoteSpaceBefore=320→ heading After grows to 320, no spacer between.dotnet test325/325 passing, 0 errors, 0 new warnings.Related