Repository navigation
fix(docx): break a page after a card where the layout breaks it - #964
Merged
Merged
Conversation
Where the layout breaks a page between two blocks of the body, Word and LibreOffice place the break themselves. A block kept together in a table cell chained its paragraphs with keepNext, which Word reads on the paragraph a cell opens with as keeping the whole row with what follows its table: ObsidianInvoice's info cards went to the next page with the footer divider. In a cell a kept block now keeps its lines together only. Word and LibreOffice drop a paragraph's space above at the top of a page they break themselves. A rule opening its page now holds its top edge in a line of its own, as a paragraph and a picture do, and a table, a row or a panel holds the gap the layout carries onto its page with its own edge, where it left that gap on the page above.
The closing row's gap is 12.4pt; Word set the page 13.0pt high and LibreOffice 12.8pt, as the CHANGELOG and the recipe say. Three comments gave the gap as both editors' measurement.
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.
Why
Where the layout breaks a page between two blocks of the body, Word and LibreOffice place that break themselves. Two things made them place it elsewhere. Measured in Word 16 and LibreOffice 24.2 on two invoice templates with their line items repeated (median baseline difference against the engine's PDF on the page):
ObsidianInvoice, line items ×12MeteredInvoice, line items ×9w:keepNext, in a table cell too. Word reads keep-with-next on the paragraph a cell opens with as keeping the cell's whole row with what follows its table.ObsidianInvoice's info cards, kept together in a row's two cells, went with the footer divider under them to page 5. Withw:keepNexttaken off the paragraphs the two cards open with (hand-patched), Word kept them on page 4; taken off only the separators between tables inside the cards, or only off the last paragraph of a card, it moved them still. Word also holds no keep across a break inside a row (measured for the panel keep notes), so in a cell those keeps did nothing else.MeteredInvoice's closing row opens page 4 its 12.4pt gap below the margin, and stood at the margin. The recipe named that gap as not held.pageBreakBeforeon the divider (hand-patched), Word still carried the cards to page 5, and both editors still dropped the 13pt.What changed
DocxSemanticBackend.keepOnOnePagetakes whether the block is written in the body. In a table cell its paragraphs getw:keepLinesalone. A row of columns, which may not split, keeps the block whole; elsewhere in a cell Word held none of those keeps anyway.w:keepNext, whichraiseRowsreads as its mark. Measured: a row at a page's foot whose cell opens with a card, a separator and a second card stays on its page in Word and LibreOffice with the separator'sw:keepNextor without it.writeRule: a rule opening its page in the flow holds its top edge withholdAParagraphsTopEdgeOnItsPage, as a picture does: its margin, the edges of the containers opening with it and a gap carried there, in an empty exact line kept with it.leaveThePageAboveForTheBlock(new), where a table, a row, a painted row or a panel opens its page: what the layout holds above the block there, past its own top margin, the edges of the containers opening with it and a layer's offset down a stack of one layer (named, not written), is the gap the layout carried. It is taken out of what the page above is left with and held with the block's own edge (holdTheSpaceAboveOnItsPage). The space below the block above stays on its page, as the layout leaves it there (layout probe: 6pt below a filler, a 4pt gap and a 6pt margin on the row start the row 10pt below the margin).ObsidianInvoice×12), the capability matrix's keep row, the CHANGELOG, and the keep fate in the field ledger.Where it applies
w:keepNexton paragraphs in table cells and change in nothing else; the report is unchanged (1445 notes). Converted by the same Word 16 and LibreOffice 24.2 builds before and after, every line of the 15 stands where it stood (0.00pt). No page of the corpus opens with a rule or a carried gap.MerchantInvoice,MeteredInvoice,ObsidianInvoice,PaymentsInvoice,PlatformInvoice,SubscriptionInvoiceandWorkspaceInvoice, their line items repeated 1 to 16 times. Of the 35 lengths whose layout opens a page with a block of their body, measured before and after in both editors, the two in the table move, nearer the page; the other 33 are identical page by page.Tests
DocxKeepTogetherTest(+2): a block kept together in a row's cell keeps its lines together and nothing with the next, its row kept whole; two painted cards kept together in a row's two cells keep nothing in the row with the next, and every line of theirs together.DocxBlockOpeningAPageTest(+11):DocxOneRowTableKeptWithTheNextTest— a heading kept with the next in a row's column, and a row kept with the next inside a card, keep nothing with the next, their rows kept whole;DocxPanelEdgeCasesTest— a block kept together inside a card keeps its lines alone. The field ledger's keep fate says where a keep is written.InvoiceNaturalPageBreakDocxTest(qa, new, 2):ObsidianInvoice×12 — no paragraph its info cards' cells open with keeps with the next, and the footer divider opening page 5 holds its margin in a line;MeteredInvoice×9 — the closing row opening page 4 holds the gap the layout carries there.keepNext; a keep in the body writing none; a rule opening its page holding nothing; a rule holding its edge on any page; the carried gap not held; the gap reckoned with the block's own margin, with the containers' edges, or with a layer offset not written; the gap also left on the page above; a table or row, a painted row and a panel each leaving the gap above../mvnw -B -ntp -f aggregator/pom.xml clean verify -pl <core, render-pdf, render-docx, render-pptx, templates, testing, qa, coverage> -am→ BUILD SUCCESS: core 823, render-pdf 339, render-docx 2256, testing 5, render-pptx 142, templates 127, qa 1835../mvnw -f examples/pom.xml test→ BUILD SUCCESS, 93 tests.w:keepNextinside table cells alone; the report unchanged (1445 notes); in Word 16 (16.0.20527) and LibreOffice 24.2 the 15 set every line where they did, base and new converted by the same build.Named, not fixed
Lane: shared-engine (render-docx). No public API change.