@ai-matrx/print 0.8.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.8.1
4
+
5
+ - **Fixed (Word):** exporting DOCX laid out a whole PDF to number the table of
6
+ contents even when the document has no table of contents; now only with a
7
+ TOC, and a failed measuring pass never fails the export — the TOC lists every
8
+ heading and Word fills in the page numbers on open (`toc-pages-deferred`
9
+ notice).
10
+ - Consumer action: none — refresh to latest.
11
+
3
12
  ## 0.8.0
4
13
 
5
14
  - **Citations through a real CSL processor.** citeproc-js (the engine Zotero
package/dist/document.cjs CHANGED
@@ -5548,7 +5548,21 @@ async function exportDocument(source, format, options = {}) {
5548
5548
  bytes = r.bytes;
5549
5549
  pageCount = r.pageCount;
5550
5550
  } else if (format === "docx") {
5551
- const pages = tree.toc.length ? await headingPages(tree, images, options.fonts) : void 0;
5551
+ const hasToc = tree.sections.some((sec) => sec.blocks.some((blk) => blk.type === "toc"));
5552
+ let pages;
5553
+ if (hasToc) {
5554
+ try {
5555
+ pages = await headingPages(tree, images, options.fonts);
5556
+ } catch (err) {
5557
+ const n = {
5558
+ code: "toc-pages-deferred",
5559
+ message: `The Word file's table of contents lists every heading; its page numbers fill in when the file is opened (they could not be measured here: ${err.message}).`,
5560
+ remedy: "Open the file in Word (or update fields) to show the page numbers."
5561
+ };
5562
+ tree.notices.push(n);
5563
+ options.onNotice?.(n);
5564
+ }
5565
+ }
5552
5566
  bytes = await documentToDocx(tree, { images, headingPages: pages });
5553
5567
  } else bytes = await documentToEpub(tree, { images });
5554
5568
  }