Repository navigation
feat: w:cantSplit on table rows and w:keepLines on paragraphs - #3
Merged
dskripchenko merged 3 commits intoOct 20, 2026
Merged
dskripchenko merged 3 commits into
dskripchenko merged 3 commits into
Conversation
A list item's numPr was prefixed onto the finished w:pPr string, right after pStyle. CT_PPrBase is a sequence, so numPr must follow keepNext, keepLines and pageBreakBefore. renderParagraphProperties() now takes the numPr and writes it at its position. Output is unchanged today; it keeps the order valid once those elements are written.
ParagraphStyle::$keepWithNext was read from DOCX and serialized to HTML (break-after: avoid) but never written by the Word2007 writer. It is now written in CT_PPrBase order: after pStyle, before numPr and pBdr.
TableRow::$cantSplit / TableRowBuilder::cantSplit() and ParagraphStyle::$keepLines are written by the Word2007 writer (keepLines after keepNext and before numPr and pBdr; cantSplit first in w:trPr), read back by TableReader / OoxmlPropertyParser, and serialized to HTML as break-inside: avoid.
dskripchenko
added a commit
that referenced
this pull request
Oct 20, 2026
feat: w:cantSplit on table rows and w:keepLines on paragraphs (#3, conflict resolved)
Merged
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.
feat: w:cantSplit on table rows and w:keepLines on paragraphs
Summary
Three commits, each separable (each passes the full suite on its own, so they can be reviewed or cherry-picked alone):
fix: place numPr by its position in w:pPr for list items:numPris written at its CT_PPrBase position instead of being prefixed onto the finished string. No output change today.fix: emit w:keepNext in DOCX output:ParagraphStyle::$keepWithNextwas read and sent to HTML but never written to DOCX.feat: w:cantSplit on table rows and w:keepLines on paragraphs.Adds two pagination properties that the library did not support:
w:cantSpliton table rows (w:trPr): the row never breaks across pages. This is Word's "Allow row to break across pages" switched off.w:keepLineson paragraphs (w:pPr): all lines of a paragraph stay on one page. This is Word's "Keep lines together".Both are written by the Word2007 writer, read back by the reader, and serialized to HTML as
break-inside: avoid, the same waykeepNextis serialized asbreak-after: avoid.Motivation
Generated documents need to control where pages break: a table row with a signature block or a short address should not be cut in half, and a paragraph that is a unit (a clause, a caption) should move to the next page whole.
keepNextandtblHeaderexisted; these two were the missing counterparts.API
Output:
<w:trPr><w:cantSplit/></w:trPr>and<w:pPr><w:keepLines/></w:pPr>.Notes
TableRow::$cantSplit,ParagraphStyle::$keepLines), so positional callers are unaffected.w:pProrder follows CT_PPrBase:pStyle,keepLines,numPr,pBdr, ... The list-item path prefixednumPrright afterpStyle; commit 1 places it by position, afterkeepNext/keepLines. Inw:trPr(an unordered choice)cantSplitis written first, thentblHeader,trHeight.keepNext; before this it was dropped on the way into DOCX.break-inside: avoidfrom HTML back into the model (break-after: avoidis not parsed either).Tests
composer install && vendor/bin/phpunit: OK (410 tests, 1050 assertions); before: OK (398 tests, 1009 assertions). After each commit: 399, 402, 410 tests, all OK.composer stan: no errors.