From d2d90d5d9d31ae1531617123dba9d0c45df75b90 Mon Sep 17 00:00:00 2001 From: Michel Liao Date: Sat, 21 Nov 2026 14:28:28 -0500 Subject: [PATCH] fix(web): ODT previews no longer print an index's title twice or its entry separators An OpenDocument index (table of contents, bibliography, table of figures and the other four kinds) is stored as two parts: the source it is generated from, then the generated body. The ODT preview printed the text of both, so a LibreOffice table of contents showed "Table of Contents" twice, and a bibliography was preceded by a run of the separators from its entry templates (": , , : , , ..."). The reader now skips the seven index source elements and shows only the index body, which already holds the title and the entries. Claude Fable 5.2 in Claude Code, running in T3 Code. Co-Authored-By: Claude Fable 5.2 --- .../components/files/FilePreviewPanel.test.ts | 19 ++++++++++++++++++- .../files/extendedDocumentPreview.ts | 7 +++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/apps/web/src/components/files/FilePreviewPanel.test.ts b/apps/web/src/components/files/FilePreviewPanel.test.ts index 4c9d8b0f9a67..4b736d8b6622 100644 --- a/apps/web/src/components/files/FilePreviewPanel.test.ts +++ b/apps/web/src/components/files/FilePreviewPanel.test.ts @@ -519,16 +519,33 @@ Third}`; expect(result.pages[0]!.html).toBe(`${html}
`); }); + // LibreOffice writes every index as the templates it was built from, then the built index. + const indexes = [ + "table-of-content", + "illustration-index", + "table-index", + "object-index", + "user-index", + "alphabetical-index", + "bibliography", + ].map( + (name) => + `Index: IndexField notes: 1`, + ); it.each(["odt", "odp"] as const)("reads %s text and rejects unsupported XML", async (kind) => { const archive = new JSZip().file( "content.xml", - `${kind === "odt" ? "Field notes" : 'Launch planSpeaker only'}`, + `${kind === "odt" ? `Field notes${indexes.join("")}` : 'Launch planSpeaker only'}`, ); const result = await openDocument(archive, kind); expect(result.type).toBe("document"); if (result.type !== "document") throw new Error("Expected document"); expect(result.pages[0]!.html).toContain(kind === "odt" ? "Field notes" : "Launch plan"); expect(result.pages[0]!.html).not.toContain("Speaker only"); + if (kind === "odt") + expect(result.pages[0]!.html).toBe( + `

Field notes

${"

Index

Field notes: 1

".repeat(indexes.length)}`, + ); for (const source of [ ']>&external;', '

x

]>&e;', diff --git a/apps/web/src/components/files/extendedDocumentPreview.ts b/apps/web/src/components/files/extendedDocumentPreview.ts index 07a8713b0820..7d6021de6f81 100644 --- a/apps/web/src/components/files/extendedDocumentPreview.ts +++ b/apps/web/src/components/files/extendedDocumentPreview.ts @@ -288,6 +288,13 @@ async function odfHtml(node: XmlNode, archive: JSZip): Promise { "office:scripts", "draw:object", "draw:object-ole", + "text:table-of-content-source", + "text:illustration-index-source", + "text:table-index-source", + "text:object-index-source", + "text:user-index-source", + "text:alphabetical-index-source", + "text:bibliography-source", ].includes(node.name) ) return "";