You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(builder): table of contents built by index-refreshing converters; TOC entry styles #295
Found by porting a real-world template end to end (#292; epic #261, phase 4). The template matched the original in pages, words and fonts through a Stirling-PDF (LibreOffice) PDF path.
F1 — DOCX table of contents is not built by LibreOffice-based converters · blocker (small)
The builder writes the TOC as one paragraph: begin (dirty), instruction, separate, end, with an empty result.
LibreOffice imports a TOC field with an empty result as plain text, not as an index. A converter that refreshes
indexes on load (Stirling-PDF does) then has nothing to refresh, and the PDF has a heading with nothing under it.
Measured on the same filled document with Stirling-PDF 2.9.2:
Form of the field
TOC lines in the PDF
as the builder writes it (empty result, one paragraph)
0
the same inside w:sdt with docPartGallery
0
end moved to a second paragraph
23
one result run between separate and end
23
ODT text:table-of-content (builder)
23
A plain soffice --headless --convert-to pdf (LibreOffice 26.8) builds none of them, also not for a DOCX from another
generator: the difference is the converter, not the document. So the documentation sentence "LibreOffice builds it
neither from DOCX nor from ODT, also not when converting to PDF" and the text of TB9001 are too broad.
Proposed change: write the field so that its result is not empty (the end in a following paragraph, or a placeholder
result). Reword TB9001: the contents is built by Word on open and by converters that refresh indexes; a bare
LibreOffice conversion does not build it.
A raw block cannot work around this: an ODT raw root must be a paragraph, heading, list or table, so a definition that
replaces TableOfContents with raw XML loses the ODT index.
F9 — The look of the contents entries cannot be set · cosmetic
The entries take the application's default index styles. A design that sets level 1 in another weight, with its own
indents and line heights, cannot be reproduced.
The DOCX part is done on feature/builder (329f2ac): the TOC field's end sits in a paragraph of its own; verified through Stirling-PDF — the contents is built with page numbers. TB9001 and the docs are reworded. Still open here: TOC entry styles (F9).
F9 (TOC entry styles) done on feature/builder (73571a9..78036d8). F1 was done earlier, so #295 is complete.
API.c.TableOfContents(3, toc => toc.Level(1, Styles.TocPart).Level(2, Styles.TocSection)). The JSON form is {"toc": {"maxLevel": 3, "levels": {"1": "TocPart"}}}. A level without an entry style keeps the application's style.
Output per format.
DOCX: Word's "toc 1" … "toc 9" styles (ids TOC1 …), each based on the chosen entry style. LibreOffice maps them to "Contents N".
ODT: the entry templates name the chosen styles.
Behaviour shared by both formats. Entry styles apply to the whole document, as DOCX requires: a table of contents that sets none uses the others' styles.
Build checks.
The entry style must be defined (TB2010).
It must not be a heading (TB8002).
Two tables of contents must agree on the style for each level (TB8003).
No user style may take the id TOCn or the name "toc n" of a styled level (TB2001/TB2002).
Verification. Checked with Stirling-PDF, which refreshes indexes. The DOCX and ODT entries sit at the same positions to a hundredth of a point. Level 1 is bold with space before, level 2 is indented by 20 mm. There is no automated Stirling test, since it needs the external service; the repository tests cover the XML, the checks and the JSON round trip.
Review fixes, each with a test.
A user style TOC1 / "toc 1" produced a duplicate style id, which is invalid DOCX.
A styled and an unstyled table of contents diverged between the formats.
A "levels" value that is not an object was silently ignored.
Deferred minors.
Leading zeros are accepted as level keys ("01").
A level out of range gets a coarse error location.
The composer's dictionary is shared with the model.
Activity
fix(builder): table of contents field ends in its own paragraph, so i…
vaceslav commentedon Nov 26, 2026
The DOCX part is done on
feature/builder(329f2ac): the TOC field'sendsits in a paragraph of its own; verified through Stirling-PDF — the contents is built with page numbers. TB9001 and the docs are reworded. Still open here: TOC entry styles (F9).feat(builder): table of contents entry styles (#295)
docs(builder): table of contents entry styles (#295)
fix(builder): review of the table of contents entry styles (#295)
docs(builder): entry styles are document-wide (#295)
vaceslav commentedon Dec 1, 2026
F9 (TOC entry styles) done on
feature/builder(73571a9..78036d8). F1 was done earlier, so #295 is complete.API.
c.TableOfContents(3, toc => toc.Level(1, Styles.TocPart).Level(2, Styles.TocSection)). The JSON form is{"toc": {"maxLevel": 3, "levels": {"1": "TocPart"}}}. A level without an entry style keeps the application's style.Output per format.
TOC1…), each based on the chosen entry style. LibreOffice maps them to "Contents N".Behaviour shared by both formats. Entry styles apply to the whole document, as DOCX requires: a table of contents that sets none uses the others' styles.
Build checks.
TOCnor the name "toc n" of a styled level (TB2001/TB2002).Verification. Checked with Stirling-PDF, which refreshes indexes. The DOCX and ODT entries sit at the same positions to a hundredth of a point. Level 1 is bold with space before, level 2 is indented by 20 mm. There is no automated Stirling test, since it needs the external service; the repository tests cover the XML, the checks and the JSON round trip.
Review fixes, each with a test.
TOC1/ "toc 1" produced a duplicate style id, which is invalid DOCX."levels"value that is not an object was silently ignored.Deferred minors.
"01").vaceslav commentedon Dec 2, 2026
Done on feature/builder, merged to main in #316 and released in builder 0.1.0.