Files
docx/scripts/layout-probes/table-formatting.word.docx
Dolan e6031beed6 test(layout): check table-formatting against Word's save, and every line of a demo against Word's PDF (#3662)
* test(layout): check table-formatting against Word's save, and every line of a demo against Word's PDF

Word 16 for Mac opened the table-formatting demo on 2026-10-02, with No to
updating fields, and saved it as table-formatting.word.docx and .word.pdf.
The demo on master writes the same .docx Word opened, apart from the times
in docProps/core.xml. Adding the save to scripts/layout-probes makes
compare-layout lay it out through the .docx adapter and check its 24
headings against the pages Word marked, as for the other demos. All 24 are
on Word's page, and so are its 9 pages.

demo-lines.ts checks every line of a demo, and every row of its tables,
against Word's PDF, not only the headings. All 195 lines and rows of
table-formatting are on Word's page, the lines within 0.3 points of
Word's. It also finds every line on Word's page in five other demos, and
one difference in tables-across-pages: docx/layout leaves survey 9's
header row alone at the bottom of page 14, where Word moves it to page 15
with the first row.

* fix(layout): fail the line check when Word breaks a row docx/layout keeps whole

demo-lines.ts kept what was left of the text of a row Word broke across
pages, to find the rest on the next page, but never checked that it was
found. Where docx/layout kept the row whole on one page, nothing looked
for the rest, and the check passed though Word had put part of the row on
another page. Any row still left at the end now fails. A cell not found
among Word's lines, such as one whose text runs up it, leaves nothing to
find, so it doesn't count as broken. The script also prints its usage when
it isn't given both files.

Raised by CodeRabbit's review of #3662.
2026-10-02 20:56:26 +01:00

19 KiB