Skip to content

Suppress paragraph space-before at page tops - #431

Merged
JSv4 merged 1 commit into
mainfrom
agent/issue-428-page-top-spacing
Aug 13, 2026
Merged

Suppress paragraph space-before at page tops#431
JSv4 merged 1 commit into
mainfrom
agent/issue-428-page-top-spacing

Conversation

@JSv4

@JSv4 JSv4 commented Aug 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • model Word paragraphs explicitly in measured pagination blocks, including outline-level paragraphs rendered as h1h6
  • centralize page-top margin resolution so fit calculations and painted clones make the same section-aware decision
  • suppress paragraph space-before only for the first paragraph on later pages of the same section
  • preserve document/section-start spacing, ordinary inter-paragraph collapsing, and non-paragraph block margins
  • add a generated four-page DOCX regression for natural overflow, w:pageBreakBefore, section starts, and same-page spacing, plus direct hard-break/heading/non-paragraph probes
  • record the tracked legal-contract improvement and update its live disposition

Why this belongs in the paginator

The converter must preserve the authored w:spacing/@w:before; whether Word paints it depends on where pagination places the paragraph. The paginator now records paragraph semantics during measurement and applies one page-placement rule to keep-with-next chain sizing, ordinary body budgeting, fresh-page fallback, and the cloned block that is rendered.

The rule is section-aware: page 1 of a document or section retains its authored space-before, while the first Word paragraph on a later page suppresses it. Tables and other block margins are not treated as paragraph spacing.

Verification

  • npm run typecheck
  • 42/42 pagination Playwright tests
  • 52/52 generated regression, ratchet-contract, and Word-reference-contract checks
  • npm run test:package-boundary (163 runtime/license files)
  • filtered legal-contract visual-parity run: 3/3 pages, no conversion errors
    • page 2/3 first ink: 115 px before → 99 px after (Word 100; LibreOffice 99)
    • mean SSIM: 0.69467 → 0.72874
    • mean tolerant ink F1: 0.57203 → 0.70363
    • page 2 SSIM / ink F1: 0.61400 / 0.52821 → 0.66282 / 0.68928
    • page 3 SSIM / ink F1: 0.74653 / 0.52440 → 0.79992 / 0.75813

The visual rerun used the contracted LibreOffice 25.8.7.3 and Chromium 143. Poppler was 25.03 rather than the committed ratchet's 24.02, so the full-corpus ratchet was intentionally not rewritten; the recorded comparison is before/after in the same environment.

Fixes #428

@JSv4
JSv4 marked this pull request as ready for review August 13, 2026 13:06
@JSv4
JSv4 merged commit 8eb8e37 into main Aug 13, 2026
15 checks passed
@JSv4
JSv4 deleted the agent/issue-428-page-top-spacing branch August 13, 2026 13:16
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.

Suppress paragraph space-before at the top of a new page

1 participant