Skip to content

fix(docx): hide the empty paragraph closing a cell that ends in a nested table - #801

Merged
DemchaAV merged 2 commits into
2.5-devfrom
fix/docx-table-closer-height
Oct 1, 2026
Merged

DemchaAV merged 2 commits into
2.5-devfrom
fix/docx-table-closer-height

Conversation

@DemchaAV

@DemchaAV DemchaAV commented Oct 1, 2026 •

Copy link
Copy Markdown
Owner

Why

Word ends a table cell on a paragraph, so the export closes every table nested in a cell with a hairline one, 2 twips tall (newTable).

  • Word lays these hairlines out at no height that shows. Hiding them or thinning them to 1 twip changed nothing measurable in CobaltRota.
  • LibreOffice gives each one its tenth of a point.
    • CobaltRota has a chip in a table in a table in each cell, so every row stood up to 0.3pt taller there than on the page.
    • Its last row stood 5.2pt low.

What changed

  • hideTheCellClosingMarks. After the whole document is written, every table cell is checked, nested tables included. Where a cell ends in a paragraph right after a table, and that paragraph is still the bare hairline, its mark is hidden (w:vanish), so it is not laid out. The bare hairline means:

    • structure alone: no run, field, anchor, bookmark, border, shading or section properties;
    • an exact 2-twip line;
    • no space above or below.

    A hairline holding the space under the table keeps its mark, since that space would go with it.

  • structureAlone / hide. Extracted from hideTheClosingMark, which hides the paragraph closing a document that ends in a table, so both passes share the rule.

  • Docs. CHANGELOG.md, the composed-cells row of docs/recipes/docx-export.md, and the table row of docs/architecture/backend-capability-matrix.md.

Verification

  • Full reactor gate: ./mvnw -B -ntp clean verify -pl :graph-compose-core,:graph-compose-render-pdf,:graph-compose-render-docx,:graph-compose-render-pptx,:graph-compose-templates,:graph-compose-testing,:graph-compose-qa,:graph-compose-coverage -am gives BUILD SUCCESS (1791 + 127 tests).
    • render-docx runs 742 tests.
    • After install, examples run 93 green.
    • The knowledge checks pass.
  • DocxPanelHeightTest (+5).
    • A card ending in a nested table hides that table's closing mark.
    • A table nested in a table in a card hides the inner closing mark too.
    • A card with text after its table writes that text into the paragraph that closed the table, and hides no mark.
    • A closing paragraph holding an anchored table's bookmark keeps its mark.
    • A closing paragraph holding the space below the table keeps its mark.
  • Each rule fails its own test when reverted:
    • Not hiding the marks fails the first test.
    • Not recursing into nested tables fails the second.
    • Not checking the spacing fails the space-below test.
    • Not checking that the paragraph holds nothing fails the bookmark test.
  • Template corpus (62 documents), against 2.5-dev: 33 documents change. Word renders all 33 as before. The page count stays the same in both editors, and no median drift in LibreOffice moves by more than 0.2pt.
    • CobaltRota in LibreOffice: p90 drift 3.86pt → 2.91. Its last row stands 3.5pt low instead of 5.2.
    • Better medians in LibreOffice: InvoiceMetered, InvoiceWorkspace, InvoicePayments, InvoiceSubscription, ReceiptModern.
    • A few medians in LibreOffice move by 0.04–0.08pt the other way: EngineeringResume, TealPulse, MerchantInvoice, ProposalIndigo, ObsidianInvoice.

Known limits

  • A closing paragraph holding anything stays laid out at its tenth of a point in LibreOffice: space below the table, a bookmark, or the anchor of a drawing carried there.
  • A reader who types into a hidden closing paragraph in Word types hidden text. The same holds for the paragraph closing a document, which was already hidden. Its exact hairline line already left no room to type in.
  • Word's own 0.1–0.15pt a row in CobaltRota does not come from these paragraphs and is unchanged.

Lane: shared-engine (render-docx). No public API change.

@DemchaAV
DemchaAV merged commit 6a2219d into 2.5-dev Oct 1, 2026
12 checks passed
@DemchaAV
DemchaAV deleted the fix/docx-table-closer-height branch October 1, 2026 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant