100 Commits
Author SHA1 Message Date
Dolan 8fed97ef52 chore: Version bump to 9.16.2 (#3950) 2026-11-29 00:27:01 +08:00
Dolan d15c565e4a chore: remove the deprecated functional/prefer-readonly-type rule (#3949) 2026-11-28 16:47:12 +08:00
Dolan 7871008a0b fix: number bookmark and fitText ids per document, and patched ids after the template's (#3947) 2026-11-28 16:46:51 +08:00
Dolan 802c01d3ea chore: make eslint --fix safe to run (#3948) 2026-11-28 09:59:24 +08:00
Dolan be69da3f1a fix: number drawing ids within each document when it is packed (#3946) 2026-11-28 09:35:11 +08:00
DolanandClaude Opus 5.5 c693e08796 chore: Version bump to 9.16.1 (#3943)
Claude-Session: https://claude.ai/code/session_01QzDw6XmyL15QG62FS8rSGv

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 22:18:33 +08:00
DolanandClaude Opus 5.5 2243d74c22 fix: write one w:pStyle for a paragraph with both heading and style (#3940)
A paragraph with both `heading` and `style` wrote a w:pStyle for each, and
CT_PPrBase has one, so the Open XML SDK validator rejected the document.
Word applies the last of the two, `style`, so `style` now takes the place
of `heading`, and Word shows the paragraph as it did. The layout module and
the table of contents' heading entries read the first w:pStyle, the
heading, and now read the style Word shows.

The ListParagraph that a bullet or numbered paragraph gets without a style
of its own goes in the same if/else.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 17:36:05 +08:00
DolanandClaude Opus 5.5 4da55df933 build(deps-dev): bump typescript-eslint packages from 8.72.2 to 8.74.0 (#3939)
* build(deps-dev): bump typescript-eslint packages from 8.72.2 to 8.74.0

Bumps typescript-eslint, @typescript-eslint/parser and
@typescript-eslint/eslint-plugin together. Each release peers on the other
two at the same version, so the separate Dependabot PRs (#3923, #3924,
#3925) each failed npm ci.

* build: resolve typescript-eslint's optional @typescript/native peer to our own

typescript-eslint 8.73 and later have an optional peer on
@typescript/native >=7.1.0-dev, which our TypeScript 7.0.2 alias doesn't
satisfy. npm 11 lets that through, but npm 10 (Node 20 and 22, and the
ubuntu-24.04 runner of the shape demos job) wants that day's 7.1 dev build
and fails npm ci as the lockfile doesn't have it. The override points the
peer at the @typescript/native we already install, which typescript-eslint
doesn't use while TypeScript 6 is "typescript".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 16:07:57 +08:00
Dolan f227ee1b1d chore: Version bump to 9.16.0 (#3919) 2026-11-19 04:18:10 +00:00
DolanandClaude Opus 5.5 5f626c02ba fix(layout): lay out rows that repeat their table's properties, split rows at multiple line spacing and overfull text boxes, as Word does (#3918)
* fix(layout): lay out rows that repeat their table's properties, split rows at multiple line spacing and overfull text boxes, as Word does

estimatePageNumbers stopped at three things report templates have (#3912):

- A row whose w:tblPrEx repeats the table's own w:tblW, w:tblLayout or
  w:tblInd. Properties that are the same as the table's change nothing,
  so only those that differ still stop the layout.
- A cell's line at multiple spacing at the foot of a row that breaks
  across pages, where it fits only without the space below its text.
  word-split-rows-and-boxes.docx shows Word moves it to the next page,
  unlike in the body: 69 probes, with and without borders and above a
  cell's bottom margin, all now on Word's pages.
- An inline VML text box of its own height whose text is taller than
  it. Word cuts the text off and keeps the box's height (OB1 in the same
  probe), so the box is laid out at its own height.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(layout): compare a row's table properties with the table's whatever order their attributes are in

XML gives attributes no order, so a row's w:tblPrEx written with
w:type before w:w is the same as the table's w:tblW written the other
way round. The comparison now sorts each element's attributes first,
as a text frame's are compared, rather than stopping the layout there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(layout): put the probe's text box shape type before whichever box ONLY leaves first

The shape type was added to OB1a's box, so a run with ONLY=OB1b wrote a
box referring to a shape type the document didn't declare. It now goes
before the first box in the document, whichever that is. A full run
writes the same document as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 04:14:34 +00:00
Dolan dc8bd21a0c chore: Version bump to 9.15.4 (#3905) 2026-11-14 02:18:56 +00:00
DolanandClaude Opus 5.5 ebd29699d5 chore: Version bump to 9.15.3 (#3891)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 23:07:42 +00:00
Dolan aa47895fe8 chore: Version bump to 9.15.2 (#3883) 2026-11-03 15:45:20 +00:00
DolanandClaude Opus 5.5 11c85a281c chore: Version bump to 9.15.1 (#3875)
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 15:09:32 +00:00
DolanandClaude Opus 5.5 ea6bff070c docs: say a hanging paragraph's left is where the lines after the first start (#3874)
The `left` row in the indentation table ended with "With `hanging`, of
the lines after the first", which has no verb and doesn't say what
`left` does there. It now reads like the TSDoc on `left` in indent.ts.


Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 14:48:36 +00:00
DolanandClaude Opus 5.5 a69a60baa6 chore: sweep other merged branches in post-merge cleanup (#3873)
* chore: sweep other merged branches in post-merge cleanup

Branches from earlier PRs pile up whenever a cleanup is skipped. The
skill now checks every other local and origin branch, finds the PRs
that contain its tip by commit, and deletes it only when a merged PR
has that tip as its head or in its history and no open PR uses it.
next-major/*, gh-pages and branches in worktrees are left alone, and
anything without a merged PR is kept and reported.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* chore: delete a branch on origin only while it is at the tip that was checked

A plain `push --delete` removes whatever the branch points to when the
push runs, so commits pushed after the check would go unchecked. Both
remote deletes now lease on the checked tip: the PR's head in step 5,
and the origin tip in step 6. Git refuses the delete with "stale info"
if the branch has moved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 14:48:26 +00:00
DolanandClaude Fable 5.1 19087e8b79 fix: name images in the package as Word does, image1.png and so on (#3872)
* fix: name images in the package as Word does, image1.png and so on

Images were written to word/media under a SHA-1 hash of their data,
such as 4bf7547c9322fd2143bd3e8dfa84109d9d3fed14.png. Word for the web
has shown an empty box in place of an image named like that, and shown
it once the file was renamed image1.png as Word names its own, as
https://github.com/dolanmiu/docx/issues/496 reports.

The hash is still the key an image is added to the media under, so an
image used twice is stored once and its placeholders are unchanged, but
the file is written as image1.png, image2.jpg and so on, numbered in the
order images are added. The numbers come from the document's
PackageParts, which an ImagePatch's parts already take theirs from, so
an image never takes a part's name, nor a part an image's, and in
patchDocument new images are numbered after the template's own.

Closes #496
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QzDw6ZwCkrdX4ZsWzeVQNC

* docs: say images are numbered by type, image1.png and image1.jpg

A document's images take their names from PackageParts.takePath,
which numbers by the whole file name, so a PNG and a JPEG are
image1.png and image1.jpg, not image2.jpg as the docs and the Media
comment said. Word for the web shows images named this way, as the
images demo showed, and an ImagePatch's images were already numbered
so. The docs now say that, and a Media without a path taker numbers
its images by type too, so it names them as a document does.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QzDw6ZwCkrdX4ZsWzeVQNC

* test: a document numbers its images by type, in the order they are added

Covers a PNG, a JPEG and a second PNG written through File, which
takePath names image1.png, image1.jpg and image2.png.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QzDw6ZwCkrdX4ZsWzeVQNC

* test: check the relationships to a document's images, numbered by type

The mixed-extension test checked the media files and their bytes, but
not the relationships that point the drawings at them, which is the
XML the names matter in.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QzDw6ZwCkrdX4ZsWzeVQNC

* test: check each of a document's images is written under its own number

Swapping the two PNGs' bytes passed the mixed-extension test, though
its name says images are numbered in the order they are added.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QzDw6ZwCkrdX4ZsWzeVQNC

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-31 14:10:01 +00:00
DolanandClaude Opus 5.5 f6b4a76208 docs: show a full-page background image the header doesn't push the text below (#3871)
* docs: show a full-page background image the header doesn't push the text below

A picture behind every page goes in the header, and the paragraph holding it has a
line's height, so with small margins Word and LibreOffice start the text below it.
A negative top or bottom margin is exact, so document it with an example and a demo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* docs: say a background picture also goes in the first and even headers

With a different first page or different odd and even pages, those pages show
the first or even header, so a picture only in the default one is missing there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 11:29:00 +00:00
DolanandClaude Opus 5.5 2c4e5b43cb fix: patch placeholders in links, content controls and tracked changes (#3864)
* fix: patch placeholders in links, content controls and tracked changes

patchDocument and patchDetector only read runs that are direct children of
a paragraph, so a placeholder in a link, a content control, text typed with
Track Changes on, a smart tag or a field's result was left as it was, with
no error. Runs in those elements are now read and patched where they are.

Where the content can't go in what holds the placeholder, it goes where
Word can open it: a link is taken out of a tracked insertion (whose piece
after it gets an id of its own) or a link, a plain text content control
given more than text becomes a rich text one, and a content control
showing its placeholder text stops showing it.

Addresses #2679

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* test: cover every branch of patching runs in links and content controls

CI's coverage fell below 100%: an empty link, a content control without
properties, and runs that stay together when a tracked insertion is split
weren't tested. The name fallbacks in the replacer's lookups could never
be reached, so the lookups take an element's name as it is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* feat: find placeholders with custom delimiters with patchDetector, and say why a placeholder isn't replaced

patchDetector takes placeholderDelimiters, as patchDocument does, so it
finds the same placeholders. Before, it only knew {{ and }}, and found
nothing in a template with <<name>>.

templates.md has a section on a placeholder that isn't replaced: how to
find the patches whose placeholder isn't in the template with
patchDetector, as patchDocument leaves them out without an error, and the
usual reasons, such as a key written with its braces.

Addresses #2679

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* fix: unbind a content control a patch fills, so Word doesn't put the placeholder back

Word fills a control bound to custom XML or a document property
(w:dataBinding) in from its data when it opens a document. A patched
placeholder in one came back: Word for Mac showed {{name}} from the XML,
though the control held the patch's text. The binding is now removed from
a control a patch's content goes in.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* perf: split a tracked change around a link in linear time

The stretches were built by copying the stretch so far for each element,
so a tracked insertion of n runs took n² steps to split. Each stretch is
now sliced from where it starts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* docs: list a placeholder only in alt text among the reasons a patch isn't applied

patchDetector finds placeholders in pictures' and charts' alt text, so
comparing its keys with the patches' doesn't show a text patch for one,
which leaves it as it is. It's now one of the listed reasons, saying so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* fix: don't let a start delimiter before a placeholder hide it from patchDetector

A key ran from the first start delimiter to the next end delimiter, so in
"<<unfinished <<name>>" patchDetector found "unfinished <<name", not
"name", which patchDocument patches. With one-character delimiters such as
< and >, any "<" in the text did this. A key now has no start delimiter in
it. The search from a start delimiter with no end after it also stops at
the next one, rather than going on to the end of the paragraph each time:
120,000 characters of unmatched "<" took 1.4 s, and now take no time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* test: check the link a patch puts in a content control without properties

The test only checked the control's text and its one child, so content
that lost the link would have passed it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 20:39:09 +00:00
Dolan b3c1eedfd1 fix: write ImportedXmlComponent.fromXmlString's XML without an <undefined> element around it (#3863) 2026-10-29 15:52:04 +00:00
Dolan 655f050e12 docs: show a browser example in the README in place of playgrounds on docx 7.1.0 (#3861) 2026-10-29 14:15:15 +00:00
Dolan d08294a09a docs: say Word's dialog shows a hanging paragraph's Left where its first line starts (#3860) 2026-10-29 13:05:58 +00:00
Dolan a75d7a3e94 docs: say a table goes next to paragraphs, never in a paragraph's children (#3859) 2026-10-28 20:10:10 +00:00
DolanandClaude Opus 5.5 027c288640 fix: write a text box of auto height 1in tall, so WPS Office fits it to its text (#3858)
* fix: write a text box of auto height 1in tall, so WPS Office fits it to its text

Since 9.8.0 (#3541) WPS Office draws Textbox, which it showed blank
before (#3171), but it makes a box of auto height too short by its top
and bottom insets, cutting off the text's last line. Word, WPS,
LibreOffice and Pages all fit the box to its text from any definite
height of 8pt or more (mso-fit-shape-to-text is always written), so a
text box without a height, or with "auto", is now written 1in tall.
Word's and LibreOffice's layouts are unchanged; docx-preview, which
doesn't fit the box, draws it 1in tall rather than at its own default.

text-box.md's "Fixed Size" section said a height fixes the box's size,
which none of those applications do, so Sizing now says what height
does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* docs: say a text box needs a style with a width, and that a style's missing height is written 1in

The docs said any text box without a height is written 1 inch tall, but
a text box with no style is written without one. Such a box has no width
either: Word draws it 50pt wide and LibreOffice gives it none, and
writing height:1in on it changes neither, so it stays without a style.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 14:16:24 +00:00
DolanandClaude Opus 5.5 2f82dcb464 docs: explain legal style numbering, for 1.1 under a level in Chinese counting (#3857)
A level's text shows each level's number in that level's format, so
"%1.%2" under a level in Chinese counting is 一.1 (#3425).
isLegalNumberingStyle writes w:isLgl, which makes every number in the
text a decimal number, as Word's Legal style numbering does, but the
docs never mentioned it and its TSDoc only said "legal numbering style
(e.g., 1.1.1)".


Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 13:58:35 +00:00
DolanandClaude Opus 5.5 1146a21edd docs: show how to put space between images in a paragraph (#3856)
An inline image takes its place in the line like a letter, so images
mapped into one paragraph touch (#3021). Word for Mac ignores
characterSpacing on an image's run, and margins only apply to floating
images, but a space run between them with characterSpacing gives a gap
of a set width. Images one under another take a paragraph each, with
spacing after.


Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 12:26:22 +00:00
DolanandClaude Opus 5.5 78b04e52c6 docs: give the checkbox options' real type, defaults and what alias does (#3855)
The options table named a SymbolState type that doesn't exist and marked
value as required, though both value and font are optional, defaulting
to Word's own ☒/☐ in MS Gothic. alias writes the content control's
w:alias, which Word for Mac shows as a title tab above the checkbox, so
it's described as that rather than as an accessibility label.


Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 02:40:45 +00:00
DolanandClaude Opus 5.5 b65e65324a docs: say createMathAccentCharacter is an n-ary operator's character, and point to MathAccent (#3854)
The name made #2511's asker look for a way to put it over a letter. It
writes m:chr, the character of a sum, integral or product, while accents
over math have been MathAccent in docx/math since 9.8.1.


Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 18:23:40 +00:00
Dolan 5b1ecfeceb docs: show how to style a list's numbers and bullets (#3853) 2026-10-27 17:01:00 +00:00
Dolan 19da2bf8b7 docs: explain that a table row of exact height never splits across pages (#3852) 2026-10-27 16:16:02 +00:00
Dolan 0a4ab1e836 chore: tag origin/master in the release skill, stopping if a check fails (#3851) 2026-10-27 12:58:40 +00:00
Dolan 15b515de81 chore: tag the tip of master in the release skill (#3850) 2026-10-27 12:23:43 +00:00
Dolan 54b031819b chore: add the documentation-writer skill (#3848) 2026-10-27 11:51:32 +00:00
DolanandClaude Opus 5.5 67dab3d525 chore: Version bump to 9.15.0 (#3846)
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 20:32:34 +00:00
DolanandClaude Opus 5.5 d0d19e84ad chore: add a release skill (#3847)
* chore: add a release skill

Bumps the version in a PR, then tags the merge commit and creates the
GitHub Release that publishes to npm, as for 9.14.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* chore: make every release without a feature a patch release in the release skill

The patch rule listed fixes, docs, perf and dependency bumps, so a release
of only chores, refactors or tests matched neither rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* chore: say what $VERSION stands for in the release skill

The commands use $VERSION, but nothing set it, and a variable set in one
Bash call is gone by the next.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* chore: read the whole diff of a version bump in the release skill

A count of changed lines can't show that npm install changed only the
version lines in package-lock.json, and a bump changes only three lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* chore: let GitHub find the previous release for the release notes

PREVIOUS was set in step 1, before the skill stops for the version bump
to merge, so it's gone by step 5. Working it out again with git describe
after tagging would give the new tag. Without previous_tag_name, GitHub
compares with the previous release, as in 9.14.0's notes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* chore: watch the publish run of the release just made, in the release skill

The newest run of npm-publish.yml can still be the previous release's, as
GitHub takes a moment to start the new one. Watching that would pass at
once. A release's run is listed under its tag, so filter by it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* chore: tag the version bump's own commit in the release skill

Step 4 checked that the latest commit on master was the version bump, so
a PR merged after it, such as dependabot's, stopped the release. It now
tags the bump PR's merge commit, wherever master has got to.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 20:32:03 +00:00
Dolan 922f7f5fd9 docs: say Packer.toBuffer rejects in a browser, which has no Buffer, rather than giving a Uint8Array (#3845) 2026-10-26 16:00:47 +00:00
Dolan ab3a09807c fix: emit toStream's failure to zip on its error event, as in a browser without Buffer, not as an unhandled rejection (#3844) 2026-10-26 15:30:15 +00:00
DolanandClaude Opus 5.5 66eaf1c12e feat: read the theme of a Word document or template with readTheme, and theme fonts for other scripts (#878) (#3839)
* feat: Word's themes, colors and fonts, and the theme of a Word document or template, from docx/theme (#878)

docx/theme is a new optional entry, so the main bundle stays as it is:

- Themes: the 29 themes of Word's Design > Themes gallery, each with its
  name, colors, and fonts for headings and body text, as IThemeOptions.
- ColorSchemes and FontSchemes: the 24 color sets and 26 font sets of the
  Design > Colors and Design > Fonts galleries, to mix with a theme as
  Word's Design tab does.
- readTheme: the theme of a .docx, .docm, .dotx, .dotm, .pptx, .xlsx or
  .thmx file, or of a theme1.xml, or colors or fonts Word saved on their
  own. Styles taken from a template with externalStyles then keep the
  template's theme fonts and colors (#878).

The presets are generated from Word for Mac's own theme files by
scripts/generate-word-themes.ts, which reads each one with readTheme.

In docx, a theme font can now have a font for each script (scripts, by
ISO 15924 code), in place of Office's for those scripts, so Word's themes
keep their own fonts for Japanese, Chinese and other scripts. docx also
exports parseXml and unzipFiles, which it already had, so docx/theme
reads files without bundling a second XML parser and unzipper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* refactor: read a template's theme with readTheme from docx, sharing the patcher's theme reader, without docx/theme (#878)

- Word's themes, colour sets and font sets (Themes, ColorSchemes, FontSchemes), the
  script that generated them and the docx/theme entry are dropped. #878 asks only for
  the theme of the template a document's styles come from.
- readTheme moves into the core and is exported from docx. The patcher reads the
  colours of a template's theme with the same code, so parseXml and unzipFiles stay
  internal.
- The paths of a package's parts and its relationships' targets (relationshipsPathOf,
  resolveTarget and the others) move from the patcher to src/util/package-paths.ts,
  so the theme reader in src/file can use them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* fix: read a theme in UTF-16, and inflate only a package's relationships and its theme in readTheme

- A theme, or the XML of one, that starts with UTF-16's byte order mark is read as
  UTF-16, little or big endian, as XML may be written.
- readTheme inflates a package's relationships, and then only the theme they refer to,
  so a large or damaged document, presentation or workbook part doesn't take memory or
  stop it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* fix: find a theme whose relationship's target is in another case than its part, in readTheme and the patcher

The Open Packaging Conventions compare part names without regard to case, so a
relationship's target such as "Theme/THEME1.xml" names word/theme/theme1.xml.
readTheme threw that the file has no theme, and patchDocument used Office's colours.
isSamePart, in src/util/package-paths.ts, compares them as drawing-patch already finds
a relationship's target.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 23:02:10 +00:00
DolanandClaude Opus 5.5 82b1dc132e fix: write a table lined up inline down the page in line with the text, as Word floats one with w:tblpYSpec="inline" (#331) (#3838)
A table with `float: { relativeVerticalPosition: RelativeVerticalPosition.INLINE }` was written with
`w:tblpYSpec="inline"` in its `w:tblpPr`. Word has no floating table in line with the text: it places such a table
at the top of the paragraph after it, with text beside it, and saves it back with the `inline` dropped
(`<w:tblpPr w:vertAnchor="text" w:tblpXSpec="center"/>`). So the table never stayed in line with the text, as the
option promises.

Such a table is now written in line with the text, as Word writes a table with no text wrapping: without
`w:tblpPr` or `w:tblOverlap`. Its `relativeHorizontalPosition` of left, center or right becomes its `w:jc`, as Word's
row alignment reports those of a floating table, unless the table has an `alignment` of its own. Word reads the
issue's table as not wrapping text and centered, and lays it out centered between the paragraphs before and after it.

The tables docs now show `alignment`, and say what `INLINE` writes.


Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 13:10:40 +00:00
DolanandClaude Opus 5.5 2e07d2d688 perf: make the browser bundle 29 KB smaller, zipping with fflate and hashing with docx's own SHA-1 and SHA-256 (#3834) (#3836)
* build(deps): add fflate, to zip and unzip packages in place of JSZip

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* perf: hash with docx's own SHA-1 and SHA-256, in place of hash.js

hash.js was about 6.5 KB of a browser bundle, minified and gzipped, as its whole library is bundled for the two hashes
docx uses: SHA-1 for the names of media files (`hashedId`) and SHA-256 for the password that protects a document. It
hasn't had a release since 2018, and brought `inherits` and `minimalistic-assert` with it. The platforms' own hashes
can't replace it, as browsers only hash asynchronously and documents are written synchronously.

The hashes are the same: they match FIPS 180-4's examples and node:crypto, and the password hash Word accepts is
unchanged. They are also faster: hashing a 5 MB image takes about half the time, and a password's 100,000 rounds about
130 ms rather than 155 ms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* perf: zip and unzip with fflate, in place of JSZip

JSZip was about 30 KB of a browser bundle, minified and gzipped, as its prebuilt browser file brings its own copy of
pako and more. fflate's zipSync and unzipSync, the only parts docx needs, are about 6 KB. Together with the hashes, the
bundle of a page that packs a document goes from 123 KB to 94 KB.

Nothing changes for users:
- Packer and patchDocument give each output type as JSZip gave it, including "string" and "binarystring" as a
  character for each byte, a Blob with the .docx or .docm MIME type, and the same errors for "nodebuffer" without
  Buffer, a Blob without Blob, and "text", which JSZip never gave.
- patchDocument and patchDetector still take a JSZip instance, which is read through its generateAsync, so the types
  no longer import jszip. They also still take the other forms JSZip read: a string with a character for each byte, an
  array of bytes, a Blob, an ArrayBuffer and bytes from another realm.
- A part's text keeps a byte order mark at its start, as it did.
- Packer.toStream still compiles synchronously, so it throws as before, and gives the document a turn of the event
  loop later.

Zipping is now synchronous, and faster: packing a document with 5,000 paragraphs and 5 MB of images takes 83 ms
rather than 182 ms.

The zip files no longer have folder entries, which JSZip added for each folder. Word doesn't write them, and nothing
reads them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* test: test the packer and the patcher's zip reading without JSZip

These specs mocked JSZip or read the JSZip instance the compiler returned. They now build real zip files and read
what the Packer and the patcher give, so they test the zipping too:
- loadZip reads every form a template can be given in, a JSZip instance through its generateAsync, and leaves out
  folders
- Packer.toStream throws when the document can't be written, and gives it even to a listener added after an await
- toBlob, toArrayBuffer and toStream give real zip files, rather than what a mocked compiler gave

The counts of the files in a package no longer include the folder entries JSZip added.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* test: test zipping, unzipping and each output type of a zip file

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* chore: read and write .docx files in the scripts with fflate, in place of JSZip

docx is replacing JSZip with fflate (#3834), and jszip is leaving package.json, so the scripts that read documents
(compare-layout.ts, the layout probes' line checkers) and the probes that edit docx's output before writing it use
fflate's unzipSync and zipSync. They leave out folder entries when they unzip, as Word's own files have none, and zip
at level 6. The written documents have the same files in the same order, with the same contents, as before.

check-api.ts's comment no longer says the built declarations import jszip. Those of releases up to 9.14.0 still do,
and the import, which no longer resolves, is any there, which the check accepts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* fix: load Node's types from docx's declarations, which JSZip's used to load

The declarations use Node's types, such as Buffer and NodeJS.ReadableStream. They had them because they imported
JSZip's declarations, which reference Node's types. Without JSZip, a project that doesn't load every @types package,
such as one with `types` set, or TypeScript 6's default, would find no Buffer in docx's types, and docx's own optional
entries didn't build. The reference is kept in the built declarations with `preserve="true"`, as TypeScript otherwise
leaves it out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* test: read and make zip files with fflate in the specs of charts, embedded files, macros, shapes and the core, in place of JSZip

jszip is leaving docx's dependencies, so these specs read packed documents and make changed templates with the helpers
in tests/zip, which unzip and zip with fflate, as docx now does. Each test checks what it checked before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* test: read and make zip files with fflate in the specs of docx/html, docx/layout and the patcher, in place of JSZip

jszip is leaving docx's dependencies, as docx now zips and unzips with fflate, so these specs read packed documents
and make templates with the helpers in src/tests/zip.ts. Templates that were JSZip instances are now zip files' bytes,
and the specs read text and bytes from the unzipped files directly, so some helpers that only awaited JSZip are no
longer asynchronous.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* test: patch real zip files in patchDocument's spec, rather than mocking JSZip

JSZip is leaving the dependencies. The spec mocked JSZip.loadAsync and passed an empty Buffer as the template, so
patchDocument never unzipped anything. Each template is now a real zip file, made with the specs' zip helper, so the
tests exercise the unzipping too. The tests of a template opened with JSZip pass an object with generateAsync, which
is how a JSZip instance is read now.

The path keys of the templates are covered by one file-level naming-convention exception, in place of the comments on
each patch key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* build(deps): remove jszip, as nothing uses it now

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* fix: refuse a zip file's entry of the wrong size before taking memory for it, and inflate only what patchDetector reads

fflate takes room for the size a zip file gives an entry before inflating it, so a template of a few hundred bytes
could make docx take 4 GB, which fails in a browser or a process with a memory limit. JSZip refused such an entry
("uncompressed data size mismatch"). An entry whose given size is more than DEFLATE can inflate its data to (1032
times) is now refused before fflate takes the room, and one that inflates to less than its given size after.

JSZip also inflated only the entries that were read, so patchDetector, which reads only the XML parts in word/, never
inflated a template's images or embedded files. unzipFiles and loadZip now take the paths to read, and patchDetector
gives them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* fix: refuse a zip file whose entries claim more compressed data than the zip file holds, before taking memory for them

The size an entry inflates to was checked against its compressed size, but that is also read from the zip file, so an
entry could claim compressed data larger than the zip file and pass. The entries docx reads now have their compressed
sizes added up, and a total larger than the zip file is refused before fflate takes room for the entry. Together with
DEFLATE's ratio, that keeps the room taken to 1032 times the zip file's size, as a real zip bomb's is.

The tests damage the entry's data too, so only a refusal before inflating gives their error: without either check, each
fails with fflate's own error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 00:08:58 +01:00
DolanandClaude Opus 5.5 9239334f73 docs: pipe Packer.toStream's stream straight away in the quickstart (#3835)
The quickstart called `.then` on `Packer.toStream`'s result, but it returns the stream itself, not a promise, so the
example threw "then is not a function". The Packers page already uses the stream directly.


Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 22:28:42 +01:00
Dolan ba1e9ddea9 fix: show Word's Update Table on a table of contents, by putting it in Word's Table of Contents gallery (#2598) (#3833) 2026-10-24 14:35:24 +01:00
DolanandClaude Opus 5.5 b26d269153 feat: make a new paragraph with other options from a paragraph, with Paragraph's with() (#3330) (#3831)
paragraph.with({ indent }) makes a new paragraph with the paragraph's options and those given, which replace its
own, such as to lay out the paragraphs a parser made, without casting to reach their children. The paragraph is
left as it is. paragraph.options gives the options it was made with, so an option can be extended rather than
replaced.


Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 01:00:44 +01:00
DolanandClaude Opus 5.5 2f8c8c7711 feat: patch placeholders with spaces inside their delimiters, such as {{ name }}, with trimPlaceholders (#3112) (#3830)
patchDocument's trimPlaceholders takes the spaces inside the delimiters out of the placeholders of the patches given,
even when Word splits them across runs, before patching: in the text, the fields of TABLE_ROWS patches, and the alt
text of drawings. patchDetector's trimPlaceholders gives their keys without the spaces. Both default to false.


Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 01:00:36 +01:00
DolanandClaude Opus 5.5 414b476dde fix: give a drawing whose alt text has no name an empty name, which the XML requires (#3829)
An ImageRun, ChartRun or shape whose altText was only a description, as JavaScript allows, wrote wp:docPr without
its required name attribute. The name now defaults to empty, as it does for a drawing without alt text, and is
optional in DocPropertiesOptions, so alt text can be just a description.


Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 01:00:30 +01:00
Dolan 72951b75f7 feat: replace the image of a picture in a template, keeping its look, with ImagePatch (#3072) (#3828) 2026-10-23 22:02:17 +01:00
Dolan MiuandClaude Opus 5.5 07286f3bee chore: Version bump to 9.14.0
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c
2026-10-23 04:15:59 +01:00
DolanandClaude Opus 5.5 eadca504e2 fix: define the TOC 1 to TOC 9 styles, so LibreOffice keeps the levels of a table of contents indented (#3819) (#3821)
* fix: define the TOC 1 to TOC 9 styles, so LibreOffice keeps the levels of a table of contents indented (#3819)

Since 9.9.0 a table of contents is written with its entries, in the styles
TOC1 to TOC9, which docx never defined. Opening it, LibreOffice gives its
Contents 2 to Contents 9 styles no indent, so once it updates the index every
level is flush left. 9.8.1 wrote no entries, and LibreOffice kept its own
indents.

docx now writes the styles as Word adds them: based on Normal, 5 points of
space after, and each level indented by Normal's font size more than the one
above (200 twips a level at docx's default 10 points, 220 at 11 points, as
Word for Mac writes them). They are hidden until used, as Word's are. A style
with their id replaces them, as for the other default styles, and so does a
style with their name, such as a template's "toc 1" with a localized id, so
no two styles share a name. The entries no longer need an indent of their
own, which assumed 220 twips.

Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: keep the text-and-spacing layout demo's Tab stops heading clear of the bottom of a page

The TOC styles give the table of contents' entries 5 points of space after,
as Word's do, instead of the demo's 8, so the text after the table moved up
33 points. That left the Tab stops heading and its first line ending less
than a point below the bottom margin of page 9. Word and docx/layout fit
them there; LibreOffice, which compare-layout.sh checks against, moves them
to page 10. Word and LibreOffice put every other line of the page in the same
place.

The hanging-indent paragraph above the heading has 80 words instead of 90, a
line fewer, so the heading fits with room to spare. All 368 headings of the
layout demos are now on LibreOffice's page, and Word puts this demo's on the
same pages.

Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: keep docx's TOC styles beside a character style with their name

Only a paragraph style named "toc 1" to "toc 9" takes the place of docx's
TOC1 to TOC9. A table of contents' entries are paragraphs, which can't take
a character style, so a character style named "toc 2" left the entries
naming a TOC2 that docx no longer wrote.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* fix: indent the TOC styles patchDocument adds by the template's Normal font size

Word indents each level of a table of contents by the size of the Normal
style's font, and a Document does too, but the TOC1 to TOC9 styles that
patchDocument adds to a template without them always stepped by docx's 10
points. They now follow the template's Normal: its own size, or else the
document's default size, such as the 12 points Word for Mac saves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* fix: take the TOC indent from the template's style that patchDocument bases the TOC styles on

The TOC styles patchDocument adds are based on the template's style with
Normal's id, or else on its style named Normal. Their indent now follows
the font size of that same style, so a template whose Normal has another
name still gets its size.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 04:09:31 +01:00
Dolan 799bc7f47e feat: choose what fills the space before a table of contents' page numbers, such as nothing or hyphens (#1696) (#3818) 2026-10-22 10:41:12 +01:00
DolanandClaude Opus 5.5 5050cc0bba feat: draw diagonal lines across table cells, to split a header cell (#3121) (#3817)
A cell's borders take `diagonalDown` and `diagonalUp`, Word's "Diagonal
Down Border" and "Diagonal Up Border", written as `w:tl2br` and `w:tr2bl`
after the sides, in CT_TcBorders' order. A diagonal down border splits a
header cell into a label for the columns, above the line, and one for the
rows, below it.

Checked in Word for Mac: a cell merged with columnSpan or rowSpan gets one
diagonal across the whole merged cell. docx already copies a merged cell's
borders into the cells it adds below, and Word draws the same either way,
as it keeps the diagonal on the cells below when it saves.


Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 03:18:59 +01:00
DolanandClaude Opus 5.5 8a84c5906d fix: write a half-inch default tab stop, so tabs and list text line up in Pages (#2590) (#3816)
docx only wrote w:defaultTabStop when the defaultTabStop option was set. The
spec puts a tab stop every half inch without it, and Word and LibreOffice do,
but Pages 15.1.1 puts none: a tab takes no room, and the tab after a list
number with no hanging indent sends the text to the right margin, one word to
a line. Write 720 unless the option says otherwise, as Word always does.


Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 02:37:02 +01:00
DolanandClaude Opus 5.5 b87383272d feat: cite sources and list them in a bibliography, in each of Word's styles, from docx/bibliography (#557) (#3814)
* feat(bibliography): the sources part, the styles' framework, and Word's output to test against

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* feat(bibliography): citations and bibliographies, written as Word's content controls and fields

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* test(bibliography): keep the empty paragraphs in corpus s's bibliographies of GB7714 and ISO 690

The fixtures' generator left out the paragraphs of corpus s's bibliographies that have
no text, though Word's styles write them: GB7714 and ISO 690 write an entry for a source
with no author, title or other field as an empty paragraph, which Word keeps. Corpora a
to d, Word's own output, keep empty paragraphs between entries too. Each of these
fixtures gets back its 15 empty paragraphs, from the oracle, with the others as they were.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* feat(bibliography): write citations and bibliographies in GB7714, as Word does

GB.XSL and ISO690.XSL share nearly every template, so the shared ones go
in one family module, iso-690-family.ts, with the few that differ chosen by
the variant: GB7714 cites a source with no author or year by its tag, and
the two styles put the space after a website's or a report's production
company by different fields.

The module also reads the styles' HTML as Word's import does: spaces
collapse, a space falls between two elements and at the end of a copied
variable before the end of a paragraph, and a copied element with nothing
in it leaves its formatting on for the rest of the bibliography.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* feat(bibliography): write citations and bibliographies in ISO 690 by first element and date, as Word does

ISO690.XSL is GB.XSL's twin, so the style is the ISO 690 variant of the
family module: a source with a title but no author or year is cited by
nothing, "()", where GB7714 cites it by its tag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* feat(bibliography): write citations and bibliographies in ISO 690 by numerical reference, as Word does

ISO690Nmerical.XSL cites a source by its number, with the pages or volume
cited after it, such as "(1 p. 5)", and lists the sources in the order the
document cites them. Its entries are the ISO 690 family's, with the main
contributors after the start of a journal article or conference paper.

The style copies each entry from a variable, so Word reads an entry whose
bold has nothing in it, such as one with no author, as bold that stays on
for the rest of the bibliography. An empty xsl:value-of in an element ends
it as usual, so a miscellaneous source with no publication doesn't leave
italics on, as Word's own bibliography of such a source shows; libxslt's
output differs from Word's there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* chore(bibliography): spell the styles' names and Word's abbreviations

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* test(bibliography): keep the empty entries of corpus s in the GOST and SIST02 fixtures

Word writes an empty paragraph for a source whose entry is empty in a style,
such as a miscellaneous source with no fields in GOST, as Word's style writes an
empty <p> for it. gen-fixtures.mjs dropped every empty paragraph of corpus s, so
the fixtures had fewer entries than the bibliography. They're rewritten from the
oracle with them, and gen-fixtures.mjs needs the same change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* feat(bibliography): write citations and bibliographies in GOST, as Word does

Ports Word's GOST - Name Sort (GostName.XSL) and GOST - Title Sort
(GostTitle.XSL). They share everything but how an entry starts, how the
bibliography is sorted, and a few templates, so both are written from one module,
gost-family.ts: Name Sort starts an entry with its authors in bold and leaves the
people who are those authors out of the rest; Title Sort starts it with its title
in bold, sorts by title, then the main author's names, counts an organization as a
book section's author, and writes an interview's responsibilities only when one
of the first three isn't empty.

The ports follow the templates where they do what they don't look like they do:
_MaxAuthor is read without a $, so every author is listed up to three; a role is
written only when one of its people has a last name; a location with neither a
city nor a publisher is the source's distributor; and an entry of nothing but
spaces is left empty, with no dot.

Their output matches Word's for corpora a to d and the oracle's for corpus s, and
the oracle's for 8 seeds of 300 random sources each.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* test(bibliography): end SIST02's corpus s entries without a space, as Word does

Word's SIST02 style, run with libxslt, ends an entry that ends with a bold or
italic element with a line break, which the oracle reads as a space. Word for
Mac shows none: corpus b has "<b>MoraLuz</b> <i>Bread.</i>" and
"<i>Untitled Notes.</i>", with nothing after them. Corpus s's expected
bibliography is regenerated with the oracle reading no space at the end of a
SIST02 paragraph, which changes 14 entries such as "<b>—.</b> ".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* feat(bibliography): write citations and bibliographies in SIST02, as Word does

Word's SIST02 style (SIST02.XSL), with its own full-width punctuation and
empty spaces, its name patterns, and Word's reading of its HTML: a space
between two bold or italic elements that follow each other, even an empty
one, and none at the end of an entry. Its quirks are kept, such as "ed."
after any number of editors, "Vol. 5..", "[Cited: ]" for a date accessed
with only a day, and "—." for an article whose title is the one before's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* test(bibliography): keep the empty paragraphs of corpus s's APA bibliography

Word's APA style writes a paragraph for each source, empty for a source it
has nothing to write for, such as a case with no title, number, court or date.
The fixtures' generator left out empty paragraphs, so corpus s's expected
bibliography was two entries short of what the style writes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* feat(bibliography): write citations and bibliographies in APA, as Word does

Word's APASixthEditionOfficeOnline.xsl, written in TypeScript: citations such
as "(Baker, 2010)", with the title when another source has the same first
author and initials when another first author has the same last name, and
the bibliography sorted by author, with a hanging indent.

It follows the XSL, including its quirks: the editors of a conference's
proceedings are always "Ed.", a work of art's date has no space after it
without an artist, and Word reads a space after an entry that ends in
italics, where MSXML writes a line break at the end of the copy of the
entry. Its citations and bibliographies are Word's for every source of the
four corpora Word wrote, and Word's XSL's for corpus s and for random sources.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* feat(bibliography): write citations and bibliographies in Harvard - Anglia, as Word does

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* feat(bibliography): write citations and bibliographies in Chicago, as Word does

Ported from Word's CHICAGO.XSL, template by template, including its quirks:
a space after an entry that ends with a title in italics, as Word's XSLT
writes a line break there, "eds." left out after a list of editors, as
Word's English has none, and no space before "Edited by" after the title
of an interview. Tested against Word's own output for the probes' corpora,
and against Word's XSL for the synthetic corpus and the branches neither
reaches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* test(bibliography): keep the empty paragraph Turabian writes for an artwork with nothing to write

Corpus s's fixture left out the paragraph Word writes for an artwork with no artist, title, institution, city or
publication title, which Turabian writes as an empty paragraph.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* feat(bibliography): write citations and bibliographies in Turabian, as Word does

Turabian's citations are Chicago's, and it finds a source's authors and sorts its bibliography as Chicago does, so
it shares those with Chicago, from chicago-family.ts. Its entries end with where and when the source was published.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* feat(bibliography): write citations and bibliographies in IEEE, as Word does

Written from Word's IEEE2006OfficeOnline.xsl: citations such as "[1, p. 50]", and a
bibliography that is a table of each source's number and entry, in the order the sources are
cited. Its people are written with the style's own templates for initials, and some of its
words are English written into the style, such as "Available:".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* test(bibliography): keep the empty paragraph MLA writes for an artwork with nothing to write

Corpus s's MLA fixture left out the empty paragraph Word writes for the work of art with none of its fields, as its generator dropped empty paragraphs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* feat(bibliography): write citations and bibliographies in MLA, as Word does

MLA, seventh edition, written from Word's MLASeventhEditionOfficeOnline.xsl: citations such as "(Baker 50)", with the title when the authors don't tell a source apart, and a bibliography sorted by the people each source is named by, with "—" for the same people as the entry before.

It writes what Word's style writes, including where that isn't what MLA asks for: editors named first with no "eds." after several of them, an organization as a performer with no "Perf." before it, an interview's title without its italics when its interviewer follows, no space between a sound recording's album and its producer when it has neither composers nor a title, and a space after an entry that ends with italics, as Word reads it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* fix(bibliography): name the style as Word for Mac finds it, and write bibliographies' paragraphs as Word does

Word for Mac only finds a style named with a slash before its file, and opens a document with
a backslash in APA. A bibliography of no sources is Word's bold "Invalid source specified.",
and IEEE's table has an empty paragraph after it, as Word writes them when it updates the
fields.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* feat(bibliography): docx/bibliography, with sources, citations and bibliographies in each of Word's styles (#557)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* fix(bibliography): reject a style named after a property every object has

createBibliography looked the style up in an ordinary object, so a name such as "toString" or "__proto__" found an inherited value, got past the check and failed later, when the document was packed. It now checks the style is one of the definitions' own keys, and throws the documented error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

* fix(bibliography): throw for a source whose type isn't one of SourceType's

A source with an unknown type, such as Word's own name "InternetSite" for SourceType.WEBSITE, was kept with no type and failed later in a style, with a TypeError. wordSourceOf now throws when the source is given, saying which source and type.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 21:49:43 +01:00
DolanandClaude Opus 5.5 9397bbd549 feat: write Word's Caption style, and document captions and cross-references (#557) (#3813)
Word gives the captions it inserts the paragraph style "caption", and docx
didn't write it, so a paragraph with `style: "Caption"` came out in Normal:
Word drops a style the document doesn't define. docx now writes the style
as Word writes it when it inserts a caption (small italic text in the
theme's second dark color, with space after), and `styles.default.caption`
changes it. A Caption style in paragraphStyles or externalStyles still takes
its place.

A new docs page shows captions with SequentialIdentifier, their numbers
written by docx/layout, cross-references to them with a bookmark and
NumberedItemReference, and a table of figures, none of which the docs
covered.


Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 16:22:38 +01:00
Dolan ba2b4e26a0 feat: protect a document from changes in Word, with a password and editable ranges (#2271) (#3810) 2026-10-21 14:09:06 +01:00
Dolan 0132938894 feat: style a section's line numbers with styles.default.lineNumber (#551) (#3808) 2026-10-20 16:29:43 +01:00
Dolan 1bfacd5c83 fix: declare that docx needs Node.js 16 or later (#3807) 2026-10-20 14:33:39 +01:00
Dolan 9382d55176 feat: set a document's properties when patching it (#2701) (#3806) 2026-10-20 14:10:34 +01:00
Dolan 437d455034 feat: embed files in a document as OLE objects, from docx/embedded-files (#719) (#3802) 2026-10-20 12:49:44 +01:00
Dolan 90bf882490 chore: evaluate-pr-comments reads CodeRabbit's comments in its reviews' bodies (#3803) 2026-10-20 12:43:36 +01:00
Dolan d71fb31dc5 feat: fit a run's text to a width with fitText (#2597) (#3801) 2026-10-20 02:55:23 +01:00
Dolan MiuandClaude Opus 5.5 c98bc7351b chore: Version bump to 9.13.0
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c
2026-10-19 23:54:18 +01:00
DolanandClaude Opus 5.5 3aaeff48b8 fix: start a numbered heading's table of contents entry with its number, with page numbers from docx/layout (#1130) (#3800)
* fix: start a numbered heading's table of contents entry with its number, with page numbers from docx/layout (#1130)

When Word fills in a table of contents, the entry of a numbered heading
starts with the heading's number, then a tab, with a tab stop past the
number. docx wrote the entries without the numbers. With page numbers
from docx/layout, the table is written clean, so Word shows it as it is
written and doesn't update it: the numbers were never shown. Word for
Mac opened such a document with "Main 2" where its own entry is
"1 Main 2".

A page number estimator can now work out the list numbers of the
paragraphs bookmarks start (listNumbers), which docx asks for once it
has bookmarked the headings, before it writes the entries.
estimatePageNumbers, and estimatePageNumbersWith's estimators, read
them as docx/layout numbers its lists, without laying out the pages. A
numbered heading's entry then starts with its number and a tab, or its
number and a space when its list follows the number with a space or
nothing, as Word writes it, and the pages are laid out with them. A
number docx/layout doesn't write as Word does is left out.

Word places the tab stop by its Normal template, not the document:
past the number, measured in Aptos 12 pt, by 240 twips, and 240 more a
level below the first, at the next multiple of 240 up to 1920, and
where it falls past that. docx places it the same way. The probes are
scripts/layout-probes/word-toc-numbers.ts and the documents Word saved
once it had updated their tables. After entries at levels 7 to 9, Word
places the stops after them on multiples of 200 instead, which docx
doesn't follow.

Checked in Word for Mac 16.114: Word opens the docs' example without
asking to update it, with "1 Introduction 2" to "2.1 Results 3", and
writes the same entries, tab stops and page numbers when it updates
the table itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: don't name the TOC number probes .word.docx, which the layout comparison lays out

scripts/compare-layout.sh lays out every scripts/layout-probes/*.word.docx
and compares the page of each heading with the pages Word marked in it,
failing for a committed one whose marks don't have all its pages. The
TOC number probes' documents are what Word saved once it had updated
their tables, saved before Word had laid out all their pages, and
aren't for laying out: the shape demos workflow failed on
word-toc-numbers.word.docx, "its marks have 2 of its 3 pages".

They are now word-toc-numbers.docx and word-toc-numbers-font.docx, as
the other probes' documents are named.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 23:49:36 +01:00
Dolan f0a176ec0b fix: don't write a table row with no cells, which Word can't open (#2724) (#3799) 2026-10-19 13:02:13 +01:00
Dolan 69fc2da10d fix: stop an index entry field scrambling the document in Word (#1546) (#3792) 2026-10-19 12:23:45 +01:00
DolanandClaude Opus 5.5 ea08b9677c feat: write macro-enabled documents with VBA macros, from docx/macros (#471) (#3791)
* feat: write macro-enabled documents with VBA macros, from docx/macros (#471)

A document's macros, the macros option, make it a macro-enabled
document (.docm): its main part has the macro-enabled content type, it
has the VBA project, word/vbaProject.bin, and Packer gives it a .docm's
MIME type. The events of the document the macros handle, such as
Document_Open, are listed in word/vbaData.xml, as Word only runs the
handlers of the events listed there.

createMacros, in a new entry, docx/macros, writes the macros from VBA
code: ThisDocument's, modules and class modules. It writes the VBA
project as [MS-OVBA] describes, in a compound file ([MS-CFB]), without
a compiled cache, so Word compiles the code when it first runs it, and
lists the events ThisDocument has handlers for. A vbaProject.bin from a
.docm Word saved goes in macros too, with the events it handles.

Checked in Word for Mac 16.114: Document_Open runs when the document
opens, and so do macros in modules that use class modules and Office's
library. LibreOffice imports the modules, and the Open XML SDK validator
passes the demos for each version of Office since 2010. The demos
workflow now validates a .docm as it does a .docx.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* fix: give a character beyond U+FFFF as two ChrW in createMacros' error

createMacros' error for a character Windows-1252 doesn't have said to
write it with ChrW and its code point, such as ChrW(&H1F600) for an
emoji. ChrW only takes a UTF-16 code unit, up to &HFFFF, so that fails
in Word. The error now gives one ChrW for each code unit: the surrogate
pair, ChrW(&HD83D) & ChrW(&HDE00), which Word for Mac turns into the
emoji. The docs say so too.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* docs: say how to run the macros of a .docm downloaded in Word for Windows

The macros docs said Word asks whether to enable a .docm's macros when
it opens. Word for Windows doesn't for a file from the internet, such
as a .docm a web page made with docx and the browser downloaded: it
blocks its macros without an Enable Content button. The docs now say to
unblock the file in its Properties, that an organization's policy can
still block macros, and that Word for Mac isn't affected.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 00:13:28 +01:00
DolanandClaude Opus 5.5 f12329161d fix: don't let a paragraph or a table type check as a paragraph's child (#2395) (#3790)
Some of ParagraphChild's classes, such as CommentRangeStart, Math and
SimpleField, have no members of their own. TypeScript compares classes
by their members, so any component, a Paragraph or a Table included,
type checked as one of them, and as a paragraph's child. Word can't open
the document that writes.

Each of them now has a private member that is only in the type, so only
it and its subclasses match it. That showed what else relied on the gap:

- Textbox is documented as a paragraph's child, so it is now in
  ParagraphChild.
- A Textbox's children go in w:txbxContent, which holds paragraphs and
  tables, as its docs show, so they are now typed as those, not as runs.
- ImageWatermark and TextWatermark now extend Run, as ShapeRun and
  ChartRun do, so they stay paragraph children. They write the same XML.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 22:36:06 +01:00
DolanandClaude Opus 5.5 7b08eacce9 fix: read an image's type from its data when it isn't given (#2952) (#3789)
TypeScript requires an ImageRun's type, but JavaScript can leave it out,
as the code in #2952 and #3305 did. The image was then written to
word/media/<hash>.undefined, which has no content type, so Word said the
document had unreadable content and Word Online wouldn't open it.

An image without a type now has it read from the bytes its data starts
with, for PNG, JPEG, GIF and BMP files, and so does an SVG image's
fallback. Data that isn't one of those is an error that says to give the
type, rather than a document Word can't read.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 21:38:46 +01:00
DolanandClaude Opus 5.5 11be8d2e82 docs: fix the CI badge in the README showing no status (#3788)
The badge used GitHub's old URL, which finds a workflow by its name and
now always shows "no status". The current URL finds it by its file,
default.yml. The badge now also links to that workflow's runs.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 18:09:17 +01:00
DolanandClaude Opus 5.5 0ffd27a95d docs: explain why TOC entries keep a heading's bold, and how to avoid it (#1369) (#3787)
When Word updates a table of contents, it copies the formatting set on a
heading's text, such as bold: true on a TextRun, onto the entry. That
takes priority over the TOC1 style, so bold: false there can't remove
it. Formatting from the heading's style isn't copied, so the fix is to
make the heading style bold instead.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 17:32:20 +01:00
Dolan 3b4f7777cd fix: patch a template read from a stream (#2321) (#3786) 2026-10-17 19:30:50 +01:00
Dolan 64c13d6af9 fix: write components from another copy of docx (#2988) (#3785) 2026-10-17 17:18:00 +01:00
Dolan 8f0a8532e4 fix: cells added below a rowSpan cell take its formatting and paragraph alignment (#1219) (#3784) 2026-10-17 16:39:04 +01:00
Dolan c08ec0ae8a feat: two lines in one and horizontal in vertical with eastAsianLayout (#1943) (#3783) 2026-10-17 15:41:30 +01:00
Dolan 65d97ee0dd docs: show how to add SVG images with a fallback (#3315) (#3782) 2026-10-17 14:15:38 +01:00
Dolan 8a91a53db9 fix: restarted list follow-ups from #3780 review (#3781) 2026-10-17 12:37:54 +01:00
Dolan 225e8c8cbb feat: restart a numbered list with numbering.restart (#3780) 2026-10-17 11:05:57 +01:00
Dolan 7907016816 fix: read and write XML without xml and xml-js, which are no longer maintained (#3779) 2026-10-17 09:44:22 +01:00
DolanandClaude Opus 5.5 be1b7d460a docs: point text frame users to ShapeRun text boxes (#3778)
* docs: point text frame users to ShapeRun text boxes

Text frames are positioned paragraphs (w:framePr), not the text box Word
makes when you insert one, which is a shape with text in it. The text
box page still recommended frames for most uses. Explain the difference
on the text frames page, with a floating ShapeRun example, and recommend
ShapeRun on the text box page.

Closes #866

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0121RHRfmgN8jDksNAdAWKnK

* docs: say how Google Docs shows text frames

Checked by converting a test document in Google Docs: the frame stays
in line, full width, and a floating ShapeRun text box is placed where it
should be.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0121RHRfmgN8jDksNAdAWKnK

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 23:42:07 +01:00
Dolan 475ba315bb fix: leave empty alt text out of wp:docPr so Word 2007 opens images (#3777) 2026-10-16 22:26:10 +01:00
Dolan MiuandClaude Opus 5.5 35496dfb15 chore: Version bump to 9.12.0
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 20:50:39 +01:00
DolanandClaude Opus 5.5 6661ec4a24 fix: Leave out a style's basedOn when it is the style's own id (#3770)
A style given basedOn its own id, such as a Normal paragraph style with
basedOn: "Normal", was written with a w:basedOn naming itself. Google
Docs can't open such a document and shows a blank page. Word leaves
the w:basedOn out when it saves the document.

A style based on itself isn't based on another, so its basedOn is now
left out, as Word does. The Chinese and Japanese demos, which gave
their Normal style basedOn: "Normal", no longer do.

Fixes #1794


Claude-Session: https://claude.ai/code/session_0121RHRfmgN8jDksNAdAWKnK

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 15:45:07 +01:00
Dolan 26d9e39842 fix: Write each part of a page number field in a run of its own, so it keeps the run's font (#3769) 2026-10-16 03:17:08 +01:00
DolanandClaude Opus 5.5 6932813623 fix: Replace list and image placeholders in one pass over each part (#3767)
Packing wrote each list's number and each image's id by running a global
regular expression over the whole part once per list instance or image,
copying the part each time. Large documents with many lists or images
spent most of their packing time, and their garbage collections, there.
Both replacers now make one pass and look each placeholder up in a map,
and finding a part's images is one pass too.

The keys were also put into the regular expression unescaped, so a list
whose reference had a character such as "(" or "." was left with its
placeholder, or matched the wrong text. They now match as written.

Fixes #2948


Claude-Session: https://claude.ai/code/session_0121RHRfmgN8jDksNAdAWKnK

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 00:53:10 +01:00
DolanandClaude Opus 5.5 1fb5e15729 fix: Size rows below a merged cell with its margins, and show how to merge cells by hand (#3766)
Word makes a row below a cell merged down rows as tall as the merged
cell's margins in it, as word-merged-cell-margins.docx shows: with
rowSpan, the cells docx adds take the table's margins, so the rows below
are as tall as the table's margins above and below and a line.
docx/layout left those cells out of the row's height, and now counts
their margins.

The table docs now show merging cells by hand with verticalMerge, which
gives the merged cell's part in each row settings of its own, such as no
margins, which keeps the rows below to a line. That is what #668 asked
for besides keeping rows together.


Claude-Session: https://claude.ai/code/session_0121RHRfmgN8jDksNAdAWKnK

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 23:27:08 +01:00
Dolan 8b8f5b1083 fix: Keep merged rows together with TableRow keepNext, and indent the numbering demo's numbers (#3765) 2026-10-15 15:26:10 +01:00
DolanandClaude Opus 5.5 7f6de64474 fix: Let a table's style give its borders (#3760)
A table always wrote `w:tblBorders` with a thin single line on every side
it wasn't given, which covered the borders of its table style. A table
with a `style` now writes only the sides `borders` gives, and none
without `borders`, so the style's borders show. Tables without a style
keep their thin single borders.

Fixes #1497

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 02:43:59 +01:00
Dolan b4ea918c5c chore: Version bump to 9.11.0 (#3758) 2026-10-13 15:49:29 +01:00
Dolan a61c85d64e feat: docx/html, HTML as a document's content (#2632) (#3752) 2026-10-13 14:53:26 +01:00
Dolan fb965994ba fix: headings in patchDocument keep their style in templates without it (#3751) 2026-10-12 15:53:25 +01:00
Dolan f5b7cea8bc fix: numbered and bulleted paragraphs in patchDocument (#3750) 2026-10-12 14:08:59 +01:00
Dolan 308329605d fix: patchDocument gives each drawing it inserts an id no other drawing has (#3749) 2026-10-12 13:43:04 +01:00
Dolan 7826217f8d docs: fix mistakes found while answering discussions (#3748) 2026-10-12 13:42:45 +01:00
Dolan MiuandClaude Opus 5.5 c9be7acae6 chore: Version bump to 9.10.0
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 13:48:07 +01:00
DolanandClaude Opus 5.5 b53aca8a3d docs: explain that only header rows at the top of a table repeat (#3745)
Word repeats a table's first row and the rows straight after it that set
tableHeader, and ignores tableHeader on rows further down. Document this,
and show how to give each part of a long table its own repeating header
by making each part a table of its own.

Closes #2425

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 13:36:50 +01:00
Dolan Miu 66901347b8 chore: Version bump to 9.9.0 2026-10-07 01:11:36 +01:00
Dolan 31b98f2e62 feat(layout): lay out compatibility modes, suppressTopSpacing, useFELayout, booklets and HTML divisions where round 26 shows Word's way, as Word does (#3730)
Word's PDFs of round 26 settled what word-stops-compat3, word-stops-top-spacing3 and -4, word-stops-booklet3, word-stops-divisions2 and word-stops-fe-layout3 probed. In Word 2010's and 2007's modes a table of a share of the width is that share of the text and its margins, a table widened for a long word grows to the room with the margins, floating tables sized to their text shift as CN9's did, text after a tab past the end goes on to 22 inches, and gaps of 1250 twips or less beside a frame are left empty; in Word 2007's mode East Asian text in its language breaks as in none and VML shapes' outlines take no room. suppressTopSpacing leaves 0.8 lines and bordered paragraphs' later lines as they are, reverse-folded booklets are the section's pages, a division's box is drawn once with its later paragraphs taking its margins and side borders, and useFELayout puts half the font's average character width between East Asian text and Latin letters or digits.
2026-10-06 22:30:48 +01:00
Dolan 22d15122e5 feat(layout): lay out bordered and Word 6 list numbers, hidden marks at sections, controls, headers and notes, and deleted rows and section breaks, as round 26 shows Word does (#3728)
* feat(layout): lay out bordered and Word 6 list numbers, the schema's other alignments, lists of one definition, hidden marks at sections, controls, headers and notes, and deleted rows and section breaks where round 26 shows Word's way, as Word does

* fix(layout): keep the section break of the paragraph a hidden mark joins to, as the next one's mark is the joined paragraph's
2026-10-06 21:47:10 +01:00
Dolan a1215475f7 feat(layout): lay out Japanese line rules, compressed punctuation, grid indents, right-to-left line ends, endnotes down the page and Arabic's letters side by side where round 26 shows Word's way, as Word does (#3726)
* feat(layout): lay out Japanese line rules, compressed punctuation, grid indents, right-to-left line ends, endnotes down the page and Arabic's letters side by side where round 26 shows Word's way, as Word does

Word's PDFs of round 26 (word-stops-east-asian3.ts and word-stops-arabic2.ts) show that Word's strict rules keep each small kana and the prolonged sound mark from the start of a line of Japanese, in place of the document's own list, and change nothing in Chinese or Korean; that compressed punctuation leaves justified Japanese and left-aligned Chinese as they are; that indents of part of a cell on a grid that snaps to characters are rounded up line by line, before the margin too, with tabs to their stops; that the space after a line's last right-to-left word takes room beside left-to-right text in a right-to-left run and between right-to-left words in any run; that endnotes after text that runs down the page run down it, and end with their section before text that runs another way; and that Word doesn't kern Arabic's letters in Arial and Times New Roman, every pair being as wide as its forms to 8 thousandths of an em. The layout follows each, and keeps a narrowed stop where a case is still open: half-width small katakana and the document's own lists beyond the strict list, distributed Japanese and justified or distributed Chinese and Korean with compression, indents a character or more before the margin, endnotes from a section followed by one that runs as it does before a change of direction, and Calibri's Arabic, which Word kerns by pairs of glyphs.

* docs: say Word doesn't kern Arabic's letters side by side in the fonts of the tables, and spell tatweels

The fonts paragraph of docs/usage/layout.md still said Word kerns them in Arial, Times New Roman and Cambria by pairs not yet known, so only Courier New's Arabic is laid out, which round 26's AR4 PDF showed to be wrong, and the probe README's ignore list lacked tatweels, which failed CSpell.

* fix: fail the Arabic kerning reader on a PDF without its probe, or a paragraph without its 42 words

Otherwise a PDF with no AR4 labels wrote {} and exited 0, and the checker reported nothing.

* fix(layout): measure Arabic's letters in their joined forms as drawn too, with ligatures or kerning on

measureTextWidthAsDrawn measured each Arabic letter in its isolated form where measureTextWidth has the forms the letters beside them join them in, so a word of Arabic in Arial with ligatures on, which no longer stops, was nearly twice as wide as Word draws it. It now takes the joined widths by each glyph's index among the characters, as the plain measurement does.
2026-10-06 21:30:57 +01:00
Dolan 0c0f1f07b9 feat(layout): lay out accents sized to their letter, cramped lower limits, spaces beside brackets, sums in a script's script, pre-scripts, phantoms, boxes and centred equation arrays, as Word's round 26 shows (#3725)
Word's PDFs of the round-26 probes (word-stops-equations3, word-stops-equation-small2) settle most of the equation stops #3702 left: roots, brackets and braces narrowed to what the PDFs still leave between two sizes, accents over a letter sized to fit it where the MATH table attaches them, superscripts in lower limits cramped, TeX's spaces beside brackets and bars, more symbols' classes, a sum in a script's script, equation arrays without ampersands centred and alignment marks left as they are, boxes struck through, phantoms without their width, ascent or descent, pre-scripts, and small fractions with displayed equations' defaults on. A scripts box now carries its base's first glyph for kerning and its last script's italic correction, which an accent leaves out. A second ampersand in a row still stops, with the sides of a box and transparent phantoms where Word's way isn't settled; word-stops-equations4.ts probes those for the next batch.
2026-10-06 21:16:24 +01:00
Dolan 1f172c6939 feat(layout): lay out phonetic guides, tabs, soft hyphens, squeezed lines, run borders, fitted text and grids above footnotes where round 26 showed Word's way, as Word does (#3729) 2026-10-06 21:10:40 +01:00