fix(layout): suppress pageBreakBefore directly after explicit break (SD-3366)#3712
Closed
tupizz wants to merge 3 commits into
Closed
fix(layout): suppress pageBreakBefore directly after explicit break (SD-3366)#3712tupizz wants to merge 3 commits into
tupizz 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
Contributor
|
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.
luccas-harbour
approved these changes
Jun 11, 2026
Contributor
|
This pull request landed on |
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
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.