From 6789377b488490f9369e9a6caae83979a4ff5f1d Mon Sep 17 00:00:00 2001 From: Steffen Becker Date: Sun, 16 Aug 2026 13:17:47 +0200 Subject: [PATCH] fix: DOCX carries the citation style and an all-off table look The b:Sources part is also the citation style's only carrier, so a document whose bibliography index sets a non-default style writes it even with no source cited. The importer keeps a declared all-off w:tblLook ('') instead of dropping it back to the default look. --- src/lib/export/docx.ts | 4 +++- src/lib/import/docx.ts | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lib/export/docx.ts b/src/lib/export/docx.ts index 9b497f6..8d4b77b 100644 --- a/src/lib/export/docx.ts +++ b/src/lib/export/docx.ts @@ -1258,7 +1258,9 @@ function bibSourceXml(s: BibSource): string { // part of their own, which needs its properties part, two relationships and a content // type — none of which the package knows about, so all four are minted here. function applyBibliographyDocx(bytes: Uint8Array, sources: BibSource[], cite: CitationStyle): Uint8Array { - if (!sources.length) return bytes; + // The part is also the citation style's only carrier (its StyleName attribute), so a + // non-default style still writes it with no sources in it. + if (!sources.length && cite === 'key') return bytes; const files = unzipSync(bytes); const relsPath = 'word/_rels/document.xml.rels'; const rels = files[relsPath] ? strFromU8(files[relsPath]) : ''; diff --git a/src/lib/import/docx.ts b/src/lib/import/docx.ts index eadaba1..2f1aa91 100644 --- a/src/lib/import/docx.ts +++ b/src/lib/import/docx.ts @@ -2359,8 +2359,9 @@ function buildTable(tbl: Element, ctx: Ctx): Node | null { if (hdr && onOff(hdr)) attrs.repeatHeader = true; if (named) { attrs.tableStyle = named; + // '' is a declared all-off look — dropping it would revert to the default look. const look = docxTableLook(fc(tbl, 'tblPr')); - if (look) attrs.tableLook = look; + if (look != null) attrs.tableLook = look; } return Object.keys(attrs).length ? { type: 'table', attrs, content: rows } : { type: 'table', content: rows }; }