fix(layout): suppress pageBreakBefore directly after explicit break (SD-3366)#3712
fix(layout): suppress pageBreakBefore directly after explicit break (SD-3366)#3712tupizz wants to merge 3 commits into
Conversation
…SD-3366) A paragraph whose style resolves pageBreakBefore, placed directly after an explicit page break, rendered an extra blank page. Word collapses the redundant break: the break paragraph's own empty remnant (its paragraph mark on the fresh page) does not re-arm pageBreakBefore, but any other content does, including a single extra empty paragraph. The existing fresh-page guard only covered pages with zero fragments, so the remnant fragment defeated it. Add a structural check on the block sequence: suppress a source=pageBreakBefore break when it is preceded by an explicit page break plus that break's empty remnant paragraph. Word-verified against a five-shape fixture matrix (break remnant, plain empty paragraph, text after break, extra empty paragraph, break at end of text paragraph); all five shapes plus both ticket fixtures now match Word's pagination. Adapter emission shapes the check relies on are pinned by new contract tests. Corpus scan: 1 of 488 docs contains the trigger adjacency.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3177add56e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…le-preceded-by-pagebreak
|
hey @tupizz! it looks good to me. can you address the comment by codex? then I think we're good to go |
An empty-text list item still paints a visible marker from paragraph attrs (numberingProperties / wordLayout.marker), so a break remnant that is a list item is page content and must re-arm a following pageBreakBefore, consistent with the Word rule that anything other than the bare remnant fires the break. Addresses PR review feedback.
|
This pull request landed on |
|
🎉 This PR is included in superdoc-cli v0.17.0 The release is available on GitHub release |
|
🎉 This PR is included in superdoc-sdk v1.16.0 |
|
🎉 This PR is included in @superdoc-dev/mcp v0.12.0 The release is available on GitHub release |
|
🎉 This PR is included in superdoc v1.40.0 The release is available on GitHub release |
|
🎉 This PR is included in @superdoc-dev/react v1.11.0 The release is available on GitHub release |
|
🎉 This PR is included in vscode-ext v2.12.0 |
Summary
A paragraph whose style resolves
pageBreakBefore, placed directly after an explicit page break (w:br w:type="page"), rendered an extra blank page. Word collapses the redundant break.Fixes SD-3366. Also the root cause behind IT-1152 (the SDT wrapper is irrelevant, confirmed in the ticket).
Root cause
The layout engine already had a fresh-page guard (
shouldSkipRedundantPageBreakBefore, added for page-forcing section breaks), but it only fires when the fresh page has zero fragments. An explicit page break paragraph leaves its empty remnant (the paragraph mark) on the fresh page, so the guard never fired and the style break added a blank page.Word semantics (fixture-verified)
Word's rule is structural, not geometric. Verified by rendering a 5-shape fixture matrix in Word:
Only the break paragraph's own remnant is forgiven; any other content re-arms the break.
Fix
isPageBreakBeforeSatisfiedByExplicitBreakinlayout-engine/src/index.ts: suppress asource=pageBreakBeforebreak when the preceding blocks are[explicit pageBreak][empty remnant paragraph]. The directly-adjacent case (shape E, no remnant emitted) was already covered by the existing geometric guard.Tests
Verification
sd-1962-nested-tables-and-sections.docx, where Word also suppresses); 10 others have both features but never adjacent, provably unchanged.