Skip to content

fix: collapse quote-table before-spacer against preceding paragraph (#78)#79

Merged
forest6511 merged 1 commit into
mainfrom
feature/quote-collapse-against-paragraph
May 5, 2026
Merged

fix: collapse quote-table before-spacer against preceding paragraph (#78)#79
forest6511 merged 1 commit into
mainfrom
feature/quote-collapse-against-paragraph

Conversation

@forest6511
Copy link
Copy Markdown
Owner

Summary

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-paragraph SpaceAfter are all handled the same way.

When the previous paragraph has no SpacingBetweenLines or After == 0, behaviour is unchanged: a fresh spacer paragraph is appended.

Test plan

  • Existing 323 tests still pass after the helper generalisation (no regression in adjacent table-table or quote-table cases — those collapse against the previous after-spacer, which still has After > 0).
  • New: AddQuote_AfterHeading_ShouldCollapseAgainstHeadingSpaceAfter — heading SpaceAfter=280 + quote SpaceBefore=160 → no spacer between, heading After stays 280.
  • New: AddQuote_AfterHeading_ShouldGrowHeadingSpaceAfterWhenQuoteWantsLargerGap — heading SpaceAfter=100 + quote SpaceBefore=320 → heading After grows to 320, no spacer between.
  • dotnet test 325/325 passing, 0 errors, 0 new warnings.

Related

#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.
@forest6511 forest6511 merged commit e1e25c3 into main May 5, 2026
1 check passed
@forest6511 forest6511 deleted the feature/quote-collapse-against-paragraph branch May 5, 2026 17:41
@codecov
Copy link
Copy Markdown

codecov Bot commented May 5, 2026

Codecov Report

❌ Patch coverage is 77.77778% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.07%. Comparing base (19fcd3e) to head (47f194c).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...kdownToDocx.Core/OpenXml/OpenXmlDocumentBuilder.cs 77.77% 0 Missing and 2 partials ⚠️
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.
📢 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.

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.

Quote (table-rendered): before-spacer not collapsed against preceding heading/text paragraph

1 participant