fix(docx): keep two tables in a row from merging into one - #732
Merged
Merged
Conversation
Word and LibreOffice join two tables with nothing between them into one, laying the second one's rows on the first one's grid; a row is written as a table, so two rows in a row merged too. A paragraph a tenth of a point tall now separates them, carrying the rest of the gap the layout keeps and the fill of the panel they sit in. Space owed below a table no longer lands on the paragraph above it: after a table is written the paragraph before it stops being the one that carries owed space, so a card ending in a table no longer opens its bottom padding between its title and the table.
On a lone paragraph between two tables a stroked panel's borders drew a rule across the card at every junction; the separator now keeps the fill only. It also keeps with the table below it, so a keepWithNext block ending in a table stays kept and a bookmark opened on the separator counts the page the table lands on. After a table nested in a cell, space owed below it goes to the paragraph that closes the cell instead of being dropped.
DemchaAV
force-pushed
the
fix/docx-adjacent-tables
branch
from
September 23, 2026 16:51
b570ffb to
8cc8361
Compare
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
Word and LibreOffice treat two
w:tblelements with nothing between them as one table. They join the second table's rows onto the first table's column grid.The export wrote consecutive tables back to back. A row (
addRow) is written as a one-row table, so two rows in a row merged the same way.Measured in LibreOffice on a filled card holding a zebra table followed by a narrower table: the card's table came out at half its width, with text broken letter by letter ("Ro / w / one"). Found by swapping tables in the XML — each table rendered correctly on its own, and any table placed directly before the narrower one collapsed.
While fixing that, a second defect showed. Space owed below a table landed on the last paragraph written, which sits above the table. A card ending in a table followed by a page break, the end of the document or a following table put its bottom padding between the card's title and its table.
What changed
newTable: separate from a table directly above. When the body's last element is a table, a separator paragraph goes in first (separateFromTheTableAbove).w:lineRule="exact"with a height of a tenth of a point.w:before, so the second table starts where the page starts it.w:keepNext). AkeepWithNextblock ending in a table therefore stays kept, and a bookmark opened on the separator counts the page the table lands on.newTable: the paragraph above no longer carries later space.lastBodyParagraphis reset once a table is written. Space owed after the table becomes the next paragraph'sw:before, or is dropped when nothing follows, instead of going back above the table.Verification
In an editor. The card probe rendered in LibreOffice beside the engine's PNG:
Gate. Full reactor gate (
clean verifyover core, render-pdf/docx/pptx, templates, testing, qa, coverage) → BUILD SUCCESS. Examples after install: 93 green. The committedword-export-companion.docxhas no adjacent tables and did not move.New
DocxAdjacentTablesTest(9):beforeis the layout's 12pt gap less its own tenth (238 twips);w:after;pBdr, while the card's own paragraphs keep theirs;keepWithNextblock ending in a table haskeepNext;Sabotage checks:
lastBodyParagraphreset fails the page-break test;keepNextor the cell carrier fails the matching new test.The 0.1pt height is measured in LibreOffice. Word may raise so short an exact line to its own minimum, which is still under the 1pt this started at.
Lane: shared-engine (render-docx). No public API change.