Files
docx/scripts
Dolan 4b607b4bfc fix(layout): keep the space before a continuous section's first paragraph after a page break, and stop at merges across pages, as Word does (#3615)
* fix(layout): keep the space before a continuous section's first paragraph after a page break, and stop at merges across pages, as Word does

Word's PDF of word-probes.docx showed three places where docx/layout put lines
on a different page from Word without stopping:

- U7a to U7c: the first paragraph of a continuous section with a page break
  before it keeps its space before at the top of the new page, less the space
  after of the empty paragraph that ends the section before: 1440 before after
  200 is 1238 in Word (LibreOffice 1240). docx/layout left it out.
- U8a7: spaces before a page break that ends a paragraph are on a line as tall
  as the paragraph's mark, not the break. docx/layout made a 28-point break's
  line 28 points, moved it to the next page, and put the text after the break
  a page later than Word.
- U4a: a cell merged down several rows whose text doesn't fit on the page is
  broken across pages by Word. docx/layout moved the merge's last row whole and
  counted all the merged lines on the page before. It now stops there, before
  the merge's first row, until merged rows are laid out across pages.

The probe script, its reader, the .docx and Word's PDF are committed under
scripts/layout-probes, and section-start-space.ts checks U7a to U7c.

* fix(layout): move a merge's first row kept whole to the next page before stopping at the merge

A row kept whole (cantSplit, or of an exact height) that doesn't fit moves to
the next page. When it starts a merge, it moved only after the merge was
checked against the room left on the page, so the layout stopped at a merge
that fits on the next page. The row now moves first, and the merge is checked
where it goes.

* chore(layout): create the folder of the probe document's given path

word-probes.ts created build/word-probes whatever path it was given, so a path
in a folder that didn't exist failed.
2026-10-01 20:37:46 +01:00
..