342 Commits
Author SHA1 Message Date
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 d71fb31dc5 feat: fit a run's text to a width with fitText (#2597) (#3801) 2026-10-20 02:55:23 +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 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 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 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 225e8c8cbb feat: restart a numbered list with numbering.restart (#3780) 2026-10-17 11:05:57 +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
3bbc2d10b6 fix: restart every level of a numbering instance, not only the first (#3768)
* fix: restart every level of a numbering instance, not only the first (#2877)

* refactor: Type the numbering's level configurations, so a new instance reads them without a cast

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

* fix: Restart each level of a new list instance at the number its level is written with

A level's w:start is its start floored, or 1, so a start of 2.5 is written as 2. A new instance now starts the level at that
number too, rather than at 1.

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

* test: Cover a new instance of the default bullet list, which restarts only its first level

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

* test: Give a new instance's levels out of order, so the test checks each override is of the level its `level` names

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

* docs: Say that a new list instance restarts every level, each from its own start

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

---------

Co-authored-by: Dolan Miu <dolan_miu@hotmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 17:28: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 a61c85d64e feat: docx/html, HTML as a document's content (#2632) (#3752) 2026-10-13 14:53:26 +01:00
builtbysharath 677a44edd3 fix: write specVanish from its own option instead of vanish (#3746) 2026-10-12 16:33:25 +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 7826217f8d docs: fix mistakes found while answering discussions (#3748) 2026-10-12 13:42:45 +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
b40cf4940d feat(fonts): embed the bold and italic faces of a font (#3736)
* feat(fonts): embed the bold and italic faces of a font

FontOptions takes optional bold, italic and boldItalic files beside
data, the regular face. Each face is embedded as a file of its own,
with its own relationship and key, and the font table refers to it
with w:embedBold, w:embedItalic or w:embedBoldItalic. docx/layout
measures text in a face from that face's file.

* docs(fonts): make the bold and italic faces example live

Embed the four faces of Crimson Text (OFL, licence included) from
demo/assets so the example runs in the docs, and show a run in each
face. Mark FontWrapper.fontOptionsWithKey deprecated in favour of files.

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

---------

Co-authored-by: Dolan Miu <dolan_miu@hotmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 19:00:22 +01:00
vhinayindiaandvhinayindia 46494c5363 docs: explain placeholder discovery before building patches (#3713)
* docs: explain placeholder discovery before building patches

* docs: clarify placeholder detector delimiter support

---------

Co-authored-by: vhinayindia <281186805+vhinayindia@users.noreply.github.com>
2026-10-07 00:36:56 +01:00
Alex Casillas a0e2756524 fix: make frame width and height optional (#3717) 2026-10-07 00:36:45 +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
Dolan bc3180cfa6 feat(layout): keep a cell's text from the border Word draws before two that meet, and an exact row's space between cells inside its height, as Word does (#3727)
* feat(layout): keep a cell's text from the border Word draws before two that meet, and an exact row's space between cells inside its height, as Word does

Word's PDF of word-stops-tables3 (round 26) settled what the lay3-tables
probes left open. The text of the cell before two borders of different
styles that meet is kept from the border Word draws, by Word's weights for
their styles, which are back (BT7a to BT7c); where Word draws the wider, or
the next cell's over none, the layout stops, unless the cell's margin
settles it. A row of an exact height with space between cells has its own
space and its cells' borders inside its height, and only the table's edge
outside (TS16a), and a border of 3 points above an exact row is inside it
(TS16b). Half of each outer border of 3 and 6 points is inside the room a
table sized to its text fills (BT8a, BT8b), and a merged cell's text breaks
between its rows as a paragraph's lines do (RW21), as the layout had them.
A long word in cells merged across columns still stops: Word's six more
cases (LW9a to LW9f) show the word's excess handed to the columns one by
one, each taking a share of what is left, but the shares of columns that
differ fit no rule yet. word-stops-tables4.ts probes what would settle it,
for the next batch.

* ci: rerun the checks after GitHub's code scanning upload failed
2026-10-06 21:05:19 +01:00
Dolan 28defb1aac feat(layout): keep text at least half a point from a floating table, and draw the characters a run's hint moves to its East Asian font in it, as Word does (#3724)
Word's PDFs of round 26 showed the text beside a table that text flows around 0 to 10 twips from it starting where it does with no distance, and 15 twips as given (word-stops-float-distance.docx FD1a to FD1f); curly quotes, dashes, an ellipsis, a degree sign and the like in the East Asian font of a run with the hint for East Asian text, in Chinese, Japanese and English (word-stops-run-fonts.docx HA1a to HA1c); accented letters in the high ANSI font given alone or beside Courier New (HA2a, HA2b); the scripts the run-font rules leave out in the high ANSI font, or in the fonts Word falls back on from either (HA3a); and Hebrew and Arabic in the font for ASCII (HA3b). The layout follows each, and stops in a run with the hint only where the PDFs don't settle the font: an East Asian font that isn't one, Latin Extended letters outside Chinese, a combining mark, a right-to-left run, and a block the rules leave out in a run whose two fonts differ.
2026-10-06 20:14:03 +01:00
Dolan 76cde3d6a8 feat(layout): lay out VML pictures at their shapes' sizes, and a picture of one pixel at 33 points, as Word draws them (#3723)
Round 26's Word PDF of word-stops-vml-pictures2.docx (VM30a to VM30h) showed Word draws a VML picture (v:imagedata) at its shape's size, and the one-pixel picture of the first batch 33 points square whatever its shape, which VM20 had read as Word's way with every picture. A picture in the line is now a box of its shape's size, with its pixels read from its PNG, JPEG, GIF or BMP file through its part's relationships, 33 points at most across and down for a picture of one pixel. A shape of a VML shape type has the type's attributes where it gives none of its own, so Word's type for pictures gives them no outline, which also takes 0.72 points out of an object's picture's line. The layout still stops at a picture placed on the page that text flows around, one drawn past 33 points a pixel that isn't the one-pixel case or has a resolution of its own, one with no size, and one whose image isn't in the document or isn't read; word-stops-vml-pictures3 probes those for the next batch.
2026-10-06 20:08:49 +01:00
Dolan ee71db8433 fix(layout): keep text half a point from a floating table with no distance, and draw characters past ASCII in the run's high ANSI font, as Word does (#3712)
* fix(layout): keep text half a point from a floating table with no distance, and draw characters past ASCII in the run's high ANSI font, as Word does

Word's PDFs of round 25 showed the text beside a table that text flows around with no distance from the text starting 10 twips from its room (CN9, CM10), where the layout's model put it at the room's edge, and curly quotes in a run given SimSun for ASCII alone drawn in Calibri, the document's high ANSI font (CN10c, FE2c). Each of a run's fonts is now read on its own, with the high ANSI font for the blocks ECMA-376 17.3.2.26 gives it; the layout stops at characters the run's hint for East Asian text may move to the East Asian font, at scripts the rules leave out in a run whose two fonts differ, and at a distance under half a point.

* fix(layout): keep a mark in the font of the character it is on in a list number's one font

singleFontOf classified a combining mark on its own, as a character of the high ANSI font, where spansOf keeps it with the character it is on, so a list number such as a digit with an accent stopped as one of characters of both fonts.
2026-10-06 02:28:41 +01:00
Dolan c2816f8d20 feat(layout): lay out footnotes and endnotes, header pictures, cell spacing, header rows and tabs where round 25 shows Word's way, as Word does (#3709)
* feat(layout): lay out footnotes and endnotes, header pictures, cell spacing, header rows and tabs where round 25 shows Word's way, as Word does

Word's PDFs of the round-25 probes settle the cases docx/layout still
stopped at in notes (word-stops-notes2, word-stops-note-numbers, the
word-stops-endnotes-* documents, word-notes-across-pages and
word-notes-final-table) and around header pictures, contextual spacing in
cells, header rows and tabs (word-stops-edges). Where a case stays open,
the stop is narrowed to it.

* fix(layout): keep the space a cell's own blocks leave out when its table's edges leave out more

A paragraph after a table in a cell is compared with the end of the table's last row, which leaves out its
space before. The pass for the table the cell is in replaced what it left out with its own, so the paragraph
kept that space.

* fix(layout): lay out the endnotes of a section with no blocks of its own after it

Where the settings put endnotes at the end of each section, those of a section that suppresses its own go
after the next, which can have no blocks of its own, as its paragraphs are hidden. They weren't laid out at
all; now they go after the section before's last block, before the next section's first.

* docs(layout): put two doc comments back above their functions, and say what leftOut covers

* fix(layout): stop at more than 4 columns of footnotes, and don't make them

A document's w15:footnoteColumns can ask for any number of columns, and
each was made before the layout stopped. Word's Footnote and Endnote
dialog offers up to 4, so more stop, as not yet seen in Word, and the
section has no columns of footnotes to make.

* fix(layout): find where each section's endnotes go in one pass back

A section that suppresses its own endnotes puts them at the end of the
next that doesn't, and that was followed one section at a time, again
for every endnote. A long run of such sections overflowed the stack.
Each section's end is now found once, from the last section back, and
only where the settings put endnotes at the end of each section.

* fix(layout): lay out the endnotes of sections before the first block

Endnotes went after each body block, for the sections up to the next
block's, so those of sections before the first block's, whose paragraphs
are all left out as hidden, were never laid out, nor were any where the
body has no blocks at all. They now go before the first block, or alone.

* test(layout): cover a header's text box placed against its line or the page

The stop kept for a text box that text flows around in a header, placed
against its paragraph or line, is now tested for one against its line, and
one against the page is read as a drawing, as a picture there is.

* fix(layout): stop at endnotes in columns with no separator above them

The endnotes' columns start below their separator, so with an empty
separator note, which leaves none, a lone endnote at the document's end
left no start for the columns it ends in, and evening them out threw.
Word has been seen with endnotes in columns only below a separator, so
that stops, and guessing, the endnotes are laid out without evening out.

* docs(layout): say paragraphs kept before header rows go on only to the next page

The table section said the paragraphs kept with the next before a table
go on with its header rows to the next page or column. They go on to the
next page; in columns, or from the top of a page, the layout stops.

* fix(layout): cut a table row in a footnote across many pages in time

The search for where a footnote's table row is cut started from the rest
of the row and went up a line at a time, filling every earlier part of
the row again at each try, so the time grew far faster than the row: a
row of 400 lines across 7 pages took 4.7 seconds. Where the rest doesn't
fit, no part taller than the page does, so the search goes on from the
page's height, and the parts filled on a page are kept for the tries
after, filled afresh on each page as their lines may hold its number.
The cuts are the same: that row now takes 0.2 seconds, and one of 2,000
lines across 34 pages 3 seconds.

* fix(layout): stop at a left tab past the end of a later line only with a hanging indent

A tab to a left stop past the end of the line at the start of a later line
of a paragraph with a first line indent stopped, though that line starts at
the left indent, as TA9a's lines do, which Word put on a line of their own.
The stop is kept for the first line there, and for any line of a paragraph
with a hanging indent.

* fix(layout): find a line's footnote that starts on the next page afresh each time it is tried

The footnote of a line at the top of a page that starts on the next page,
after the line's others, was kept across the tries of the line, and a try
after a drawing was left out, a table placed or a column moved on to could
fit the line with all its footnotes, but still put the last on the next
page. It is now found again on each try.

* fix(layout): fill a footnote row's parts before its last in a loop

The parts of a table row in a footnote before its last were filled again
by recursion, once for each page the row had gone on to, after the parts
kept for a page were let go at its end. A row across thousands of pages
would run out of stack. They are now filled in a loop, and kept by the
rooms they were cut at one after the other rather than by a key that grew
with each page. The cuts and their times are the same.
2026-10-06 01:51:02 +01:00
Dolan 88732990f7 feat(layout): lay out compatibility modes, suppressTopSpacing, booklets and HTML divisions where Word's round 25 settled them, as Word does (#3704)
* feat(layout): lay out compatibility modes, suppressTopSpacing, booklets and HTML divisions where round 25 settled them, as Word does

Word's PDFs of round 25 (word-stops-compat2-15, -14, -12, -top-spacing2, -booklet2, -divisions and -fe-layout2, committed
in scripts/layout-probes/stops2 with their documents) settle most of what the earlier batch left open:

- Compatibility modes 14 and 12: a page break at the end of a paragraph and distributed lines as in mode 15 or as
  justified ones, no ligatures without enableOpenTypeFeatures, a tab past the end at its stop with the rest of the
  paragraph on that line, gaps beside drawings and frames down to 50 and 100 points, indented tables, tables in cells and
  tables widened for a long word, floating tables with their text at their place; in 12 and 11, East Asian text of no
  language broken only at its spaces, and a text box's outline taking no room in its line.
- suppressTopSpacing: at least a height X leaves out X less 9.6 points, whatever the line's height; a paragraph's later
  line, the space before a section's first paragraph and a table's cells are followed, multiple spacing and a line below a
  border left as they are.
- Folded booklets laid out as the section's pages; paragraphs in HTML divisions laid out from the web settings.
- useFELayout stops only at East Asian text beside other text with automatic spacing on.

It keeps stopping, narrowed, where Word hasn't shown its way, and word-stops-compat3.ts writes probes for those.

* fix(layout): measure an older mode's narrow gap beside a drawing within the paragraph's indents

The stop at gaps beside drawings narrower than Word 2010 was seen putting text in measured the whole gap, so a gap a
paragraph's left indent covers, which takes no text anyway, stopped the layout, and one an indent narrows passed by its
whole width. It now measures the room the indents leave in each gap.

* fix(layout): measure an older mode's gaps of a first line's row with its first line indent

When a paragraph's first line indent leaves the first gap beside a drawing no room, its first line may go in a later
gap of the row, which the stop at narrow gaps measured without the indent. Those gaps are now measured with it, so the
layout stops where the indent would leave less room than Word was seen putting text in. Which gap Word indents then
hasn't been seen, so the lines are laid out as before.

* fix(layout): measure only the gap that takes a first line with its first line indent

The last fix measured every later gap of a first line's row with the first line indent, so a gap that takes the second
line, after a first gap the first line fits in, was measured narrower than its room and could stop the layout. Only the
first gap the indent leaves room in, which the first line goes in, is measured with it now.

* fix(layout): let no hanging indent widen an older mode's gap beside a drawing

A first line indent less than none moved the room the stop at narrow gaps measured left of the gap, into the drawing's
room, so a gap of 80 points beside a drawing passed as 105. The stop now measures no further left than the gap itself.
Where Word starts a first line that hangs past a drawing's edge hasn't been seen, so the lines are laid out as before.

* docs(layout): say a tab line's reach is from where the paragraph's lines start, and test both sides of it

The comment called the 941.4 points Word was seen keeping text after a tab on its line "past the margin", though a
line's positions, as its tab stops, are from where the paragraph's lines start: CN5a's line ran to 18827 twips from
there, past the margin's 9026. The test now checks a line just within it as well as one past it.

* fix(layout): count only frames beside a line's row in an older mode's narrow gaps

A frame anywhere on the page whose edge was where a gap's is made the gap one beside a frame, and its stricter least
width, though the frame was lower or higher on the page. Only frames beside the line's row count now.
2026-10-06 01:11:28 +01:00
Dolan c717e7739f feat(layout): lay out grid indents, Japanese line rules and endnotes after other grids, and measure Arabic's joined forms, as Word does (#3705)
* feat(layout): lay out grids and East Asian rules round 25 settles

* feat(layout): measure Arabic in the forms Word joins it in, and end right-to-left lines as Word does

* test(layout): probes for what round 25 left open, and coverage of the round's cases

* perf(layout): look past a word for a right-to-left one only after one

* test(layout): cover a grid line's own stop

* fix(layout): stop at kerned Arabic and unseen right-to-left line ends, as Word's PDFs show

* docs(layout): say which fonts' Arabic Word kerns, apart from Courier New's

The sentence read as if Courier New's Arabic were the kerned one; it is the one Word doesn't kern. Calibri's Arabic is kerned too, as word-stops-arabic AR1 showed.

* refactor(layout): rename the right-to-left lookahead's names beside the tab code's

#3707's code for a word after a tab declares following and at in the same loop, which the lookahead's names shadowed.

* fix(layout): kern a letter on a grid that snaps to characters with the one before it in another run of its font

widthOf measures pieces of the same font together, so a pair across them is kerned; snapped started each piece afresh, so a word split across runs of one font took the cells it needs unkerned there. It now keeps the letter before across such pieces, but not after a soft hyphen's break (apart).

* fix(layout): lay out lam and alef alone in Arial, Times New Roman and Cambria, as one glyph Word doesn't kern within

unknownArabicKerning took lam and the alef after it as two letters side by side, which Word kerns, but Word joins them into one glyph, the ligature, whose width word-stops-arabic AR1 measured, so a word such as "la" alone stopped the layout for nothing.
2026-10-06 00:16:18 +01:00
Dolan bb6ffa3544 feat(layout): lay out table borders, space between cells, text running up cells, merged cells across pages and tables of a share of the width, as Word does (#3708)
* feat(layout): lay out table borders that meet, art borders, rows of their own space and borders, and borders of no width, as Word does

* feat(layout): lay out text that runs up or down a cell in tables sized to their text and rows of only it, as Word does

* feat(layout): lay out tables of a share of the width that their words don't fit, with rows that give a column different widths or start past it, and leave half their borders outside their columns, as Word does

* feat(layout): lay out table styles that keep rows whole, tables indented by a share, cells that don't wrap or fit their text in tables sized to it, and exact row heights with borders, as Word does

* feat(layout): lay out the text of cells merged down rows across pages, rows taller than a page with merged cells, footnotes and header rows, and rows taller than a column, as Word does

* docs(layout): say how tables' borders, space, rows across pages and text running up lay out, and list the round-25 probes followed

* test(layout): probe what the round-25 table probes left open, for Word's next batch

* fix(layout): keep the table's top border above a row below a header row taller than a page, which isn't repeated

* fix(layout): give a row of only a cell of text running up, without a paragraph, no height

A cell may hold only range marks, as a bookmark, with no paragraph, and one whose text runs up or down, in a row of only
such cells, failed to measure its last paragraph's mark. It needs no room, as a cell of nothing across the page.

* refactor(layout): tell art borders from lines in one place, checked against the schema

A run's, a paragraph's and a table cell's borders each told an art border from a line by its style not being one of the
lines they know, with three copies of the widest art border. They now share isArtBorder and WIDEST_ART_BORDER, and a test
reads ST_Border from wml.xsd to check that its lines, from nil to inset, are those with widths, so the rest of its styles
but custom, from apples on, are its art borders and no line is taken for one. A table border's room now comes from the
lines a run's and a paragraph's know, which are the same styles.

* test(layout): probe the border above a row of an exact height with space between cells and a thick border together

TS16a has space between cells with a border of half a point, whose 10 twips inside or outside the row's height Word's
PDF shows only just, and TS16b a thick border without the space. TS16c has both, a border of 3 points and space of 40,
so Word's next batch shows plainly where the border goes in a table with space between its cells.
2026-10-05 23:57:19 +01:00