Skip to content

9.9.0

Choose a tag to compare

@dolanmiu dolanmiu released this 07 Oct 00:14
· 14 commits to master since this release

What's Changed

New: docx/layout — lay out documents as Word does

A new docx/layout entry point that works out where everything lands on the page, the way Word does. It writes the page numbers of tables of contents, page references (including \p and their own formats), PAGE/SECTION fields and caption numbers (SEQ) "clean", so Word opens the document without asking to update fields. It can read an existing .docx (to fill in a template's page numbers or check Word's own pages), and it returns the pages of a document and what is on each. Where it meets something it doesn't follow yet, it stops and says so, or it makes a best guess if you ask it to.

What it covers:

  • Text measurement: measures text with Pretext in the page's fonts, using Word's width tables, the font files you give it, fonts the document embeds and Office's own fonts. Handles italics, the bold Word makes itself, kerning, ligatures, and letters a font lacks. Supports Greek, Cyrillic, Vietnamese, Latin Extended, Chinese, Japanese, Korean, Thai, Arabic and right-to-left text, plus East Asian font hints and high ANSI fonts.
  • Lines and paragraphs: makes each line as tall as its fonts' ascents and descents, with pictures on the baseline. Squeezes the spaces of justified and distributed lines, and covers paragraph borders, auto and contextual spacing, and indents in characters and lines. Also covers tabs (decimal tabs and tabs past the margin), soft hyphens, hyphenation, hidden text and marks, tracked changes, superscript, small caps, emphasis marks, run borders, fitted text, phonetic guides and drop caps.
  • Lists: numbers lists and places their numbers as Word does, including bordered and Word 6 list numbers and list styles.
  • Tables: sizes tables given no widths (autofit), widens columns for long words, and handles merged cells and tables inside cells. Breaks rows across pages, repeats header rows, and covers set row heights, borders that meet and space between cells. Also covers table style parts, text running up or down cells, deleted rows, floating tables, and tables a share of the page wide.
  • Sections, columns and page numbers: lays out columns of different widths and evens them out before continuous section breaks. Covers next-column sections, kept paragraphs taller than a column, gutters and booklets, and page numbers in every format, with chapter numbers and restarts.
  • Footnotes and endnotes: numbers and places them, continues them across pages, and lays them out in columns, table rows and kept paragraphs. Also covers separators and continuation separators, and endnote pages.
  • Drawings and frames: wraps text around pictures, shapes and floating tables, including drawings that overlap. Covers text frames, VML text boxes, shapes, objects and pictures, and header pictures.
  • Equations: lays out linear and built-up equations and follows the document's math settings. Covers accents, limits, brackets, scripts and pre-scripts, phantoms, boxes and equation arrays.
  • East Asian layout and compatibility: covers document grids, text running down the page, Japanese line rules, compressed punctuation and grid indents. Supports compatibility modes 11, 12 and 14, suppressTopSpacing, useFELayout, HTML divisions, and imported documents (w:altChunk).
  • Verified against Word: layout probes and Word's PDFs of them are kept in scripts/layout-probes, and every line of each demo is checked against Word's own output.
All layout PRs

#3591, #3592, #3593, #3595, #3596, #3600, #3602, #3603, #3604, #3605, #3606, #3607, #3608, #3609, #3610, #3611, #3612, #3613, #3614, #3615, #3616, #3617, #3618, #3619, #3620, #3621, #3622, #3625, #3626, #3627, #3628, #3629, #3630, #3631, #3632, #3633, #3634, #3635, #3636, #3637, #3638, #3639, #3640, #3641, #3648, #3649, #3650, #3651, #3652, #3653, #3654, #3655, #3656, #3658, #3659, #3660, #3661, #3662, #3663, #3664, #3665, #3666, #3667, #3668, #3669, #3670, #3671, #3672, #3673, #3674, #3675, #3676, #3677, #3678, #3679, #3680, #3681, #3682, #3683, #3684, #3685, #3686, #3687, #3688, #3689, #3690, #3700, #3701, #3702, #3703, #3704, #3705, #3706, #3707, #3708, #3709, #3710, #3711, #3712, #3723, #3724, #3725, #3726, #3727, #3728, #3729, #3730

Other changes

  • fix: add the separate field character to PageReference by @dolanmiu in #3573
  • fix: call super() once in ImageRun so it works under Turbopack by @dolanmiu in #3574
  • build(deps-dev): bump prettier from 3.9.8 to 3.9.9 by @dependabot[bot] in #3575
  • build(deps): bump @types/node from 26.6.2 to 26.6.3 by @dependabot[bot] in #3576
  • fix: patchDocument inserts a Bookmark inline, with an id the template doesn't use by @dolanmiu in #3579
  • fix: write a bookmark inside another bookmark by @dolanmiu in #3580
  • fix: work through the unresolved review comments on recently merged PRs by @dolanmiu in #3581
  • chore: evaluate-pr-comments commits the fixes, then replies to and resolves every thread by @dolanmiu in #3582
  • fix: throw for a drawing too big for Word to open by @dolanmiu in #3583
  • fix: keep paragraph and character styles given with externalStyles by @dolanmiu in #3584
  • fix: write the same document when it is packed again by @dolanmiu in #3585
  • fix: write the images and lists in endnotes by @dolanmiu in #3586
  • fix: keep LEFT and RIGHT on their side of the page in a right-to-left paragraph by @dolanmiu in #3587
  • fix: keep embedded fonts when the document is saved again by @dolanmiu in #3588
  • feat: footnotes and endnotes in patchDocument by @dolanmiu in #3589
  • fix: write the entries of a table of contents from the headings by @dolanmiu in #3590
  • feat(table): write cells' widths from columnWidths and Word's default cell margins, so tables look and lay out the same in Word by @dolanmiu in #3594
  • chore: leave Claude Code's worktrees in .claude out of lint and the tests by @dolanmiu in #3599
  • docs(page-numbers): show how to leave pages out of the total with PageNumber.TOTAL_PAGES_IN_SECTION by @dolanmiu in #3597
  • feat(patcher): repeat the rows of a table in a template for each row of data, with PatchType.TABLE_ROWS by @dolanmiu in #3598
  • fix(patcher): format a patched link's text as the placeholder is, and add its relationship only where it's used by @dolanmiu in #3601
  • build(deps-dev): bump cspell from 10.3.4 to 10.3.5 by @dependabot[bot] in #3623
  • build(deps-dev): bump markdown-it from 14.3.0 to 14.3.2 in the npm_and_yarn group across 1 directory by @dependabot[bot] in #3624
  • build(deps-dev): bump eslint-plugin-jsdoc from 64.5.4 to 65.0.0 by @dependabot[bot] in #3642
  • build(deps-dev): bump typescript-eslint from 8.70.1 to 8.71.0 by @dependabot[bot] in #3644
  • build(deps-dev): bump @microsoft/api-extractor from 7.59.2 to 7.59.3 by @dependabot[bot] in #3646
  • docs: say how theme fonts and colors in external styles work by @dolanmiu in #3647
  • ci: upload coverage with codecov-action v5 by @dolanmiu in #3691
  • build(deps-dev): bump eslint-plugin-jsdoc from 65.0.0 to 65.0.1 by @dependabot[bot] in #3699
  • build(deps-dev): bump vite from 8.3.1 to 8.3.2 by @dependabot[bot] in #3698
  • build(deps): bump @types/node from 26.6.3 to 26.6.4 by @dependabot[bot] in #3697
  • build(deps-dev): bump @vitest/ui from 5.0.2 to 5.0.3 by @dependabot[bot] in #3696
  • build(deps-dev): bump @vitest/coverage-v8 from 5.0.2 to 5.0.3 by @dependabot[bot] in #3695
  • build(deps-dev): bump globals from 17.12.0 to 17.13.0 by @dependabot[bot] in #3694
  • build(deps-dev): bump cspell from 10.3.5 to 10.3.6 by @dependabot[bot] in #3693
  • build(deps-dev): bump vitest from 5.0.2 to 5.0.3 by @dependabot[bot] in #3692
  • build(deps-dev): bump vite-plugin-dts from 5.1.1 to 5.1.2 by @dependabot[bot] in #3718
  • build(deps-dev): bump eslint-plugin-jsdoc from 65.0.1 to 65.0.2 by @dependabot[bot] in #3719
  • build(deps-dev): bump eslint-plugin-unicorn from 76.0.0 to 77.0.0 by @dependabot[bot] in #3721
  • build(deps-dev): bump eslint from 10.11.0 to 10.12.0 by @dependabot[bot] in #3720
  • fix: make frame width and height optional by @alexvcasillas in #3717
  • feat: add a locked option to SimpleField by @alexvcasillas in #3716
  • feat: add footnote and endnote properties to section options by @alexvcasillas in #3715
  • docs: explain placeholder discovery before building patches by @vhinayindia in #3713
  • build(deps-dev): bump source-map-js from 1.2.1 to 1.2.2 in the npm_and_yarn group across 1 directory by @dependabot[bot] in #3731
  • fix: write section properties into the last paragraph of each section by @alexvcasillas in #3714

New Contributors

Full Changelog: 9.8.1...9.9.0