Repository navigation
Start a table with page-break-before on a new page - #576
Merged
jakejackson1 merged 2 commits intoSep 30, 2026
Merged
Conversation
jakejackson1
force-pushed
the
fix/552-table-page-break-before
branch
from
September 29, 2026 08:39
f0bd433 to
41833c0
Compare
jakejackson1
force-pushed
the
fix/552-break-properties
branch
from
September 29, 2026 09:49
9dac6e8 to
c2def87
Compare
jakejackson1
force-pushed
the
fix/552-table-page-break-before
branch
from
September 29, 2026 09:49
41833c0 to
829702f
Compare
jakejackson1
force-pushed
the
fix/552-table-page-break-before
branch
from
September 29, 2026 22:21
829702f to
96fcd6b
Compare
jakejackson1
force-pushed
the
fix/552-break-properties
branch
2 times, most recently
from
September 29, 2026 22:23
601dc86 to
fea9f80
Compare
jakejackson1
force-pushed
the
fix/552-table-page-break-before
branch
from
September 29, 2026 22:23
96fcd6b to
be9b439
Compare
`page-break-before` and `break-before` on a table were never read, so
`table { page-break-before: always }` left the table on the page before.
On a top-level table, `always`, `left` and `right` now break the page as
they do before a block. The break comes before the table closes the blocks
it opens in, so those blocks are opened again around the table on the new
page. The steps of the forced break move to `Tag::forcePageBreak()`, which
`page-break-after` on blocks and tables uses as well.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jakejackson1
force-pushed
the
fix/552-table-page-break-before
branch
from
September 29, 2026 23:45
be9b439 to
e836647
Compare
jakejackson1
force-pushed
the
fix/552-break-properties
branch
from
September 29, 2026 23:45
fea9f80 to
def1400
Compare
Member
Author
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.
Stacked on #569.
Problem
page-break-beforeon a table was ignored.table { page-break-before: always }with<p>aa</p><table>…bb…</table>leftbbon page 1.Table::open()readPAGE-BREAK-AFTERandPAGE-BREAK-INSIDEbut neverPAGE-BREAK-BEFORE, sobreak-before: pagefrom #569 did nothing on a table either.Change
Table::open()looks ahead at a top-level table's CSS withPreviewBlockCSS(), the look-aheadBlockTag::open()uses. Foralways,leftorrightit breaks the page before doing anything else. That order matters. The forced break closes the open blocks and opens them again on the new page, andTable::open()then draws the top of those blocks before the table. With the break later inopen(), a table inside a bordereddivwas drawn above thediv's reopened border instead of inside it.Tag::forcePageBreak(): save the block and inline state,_preForcedPagebreak(),AddPage()to the next page, odd page or even page,_postForcedPagebreak(), then restore.page-break-afteron blocks (BlockTag::close()) and tables (Table::close()) had identical copies of those steps, and now call the helper too.page-break-afterandpage-break-inside.Not in this PR:
page-break-before: alwayson a row, andpage-break-after: avoidprotecting only one line. Neither is a quick fix; both stay in #552.No existing snapshot fixture changed.
Tests
TablePageBreakBeforeTest:always,break-before: page,rightandleftwith mirrored margins, and a rule in a style sheet. Each starts the table on the page it names, and the text after the table follows it.auto,avoidand a nested table do not break.TextRecordingMpdfrecords the top of each line it draws as well, for that test.TablePageBreakBeforeSnapshotTest(table-page-break-before) has three pages, each with a caption saying what should be seen:break-before: pageinside a red box, drawn on page 3 inside the box, which is drawn again around it;page-break-before: alwaysthat stays in its cell.Before this change the whole document was on one page.
With the source changes reverted, the new tests fail.
Checks
composer test: OK. 4524 tests, 31 skipped for missing optional packages or ungenerated data. The snapshot suite ran with Imagick and Ghostscript.composer cs: clean.Part of #552. Part of #520.
🤖 Generated with Claude Code