js.documents 2.0.0 → 2.2.0

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.
Files changed (91) hide show
  1. package/README.md +49 -29
  2. package/dist/codecs/registry.cjs +14 -0
  3. package/dist/codecs/registry.js +14 -0
  4. package/dist/convert/capability.cjs +10 -0
  5. package/dist/convert/capability.js +10 -0
  6. package/dist/convert/codec.cjs +30 -0
  7. package/dist/convert/codec.d.cts +7 -1
  8. package/dist/convert/codec.d.ts +7 -1
  9. package/dist/convert/codec.js +27 -3
  10. package/dist/convert/composition.cjs +49 -7
  11. package/dist/convert/composition.d.cts +12 -5
  12. package/dist/convert/composition.d.ts +12 -5
  13. package/dist/convert/composition.js +49 -7
  14. package/dist/convert/convert.cjs +48 -0
  15. package/dist/convert/convert.d.cts +30 -1
  16. package/dist/convert/convert.d.ts +30 -1
  17. package/dist/convert/convert.js +37 -1
  18. package/dist/convert/local.cjs +4 -1
  19. package/dist/convert/local.js +4 -1
  20. package/dist/convert/port.cjs +2 -0
  21. package/dist/convert/port.d.cts +5 -0
  22. package/dist/convert/port.d.ts +5 -0
  23. package/dist/convert/port.js +2 -0
  24. package/dist/csv/read.cjs +85 -0
  25. package/dist/csv/read.d.cts +10 -0
  26. package/dist/csv/read.d.ts +10 -0
  27. package/dist/csv/read.js +84 -0
  28. package/dist/csv/records.cjs +85 -0
  29. package/dist/csv/records.d.cts +10 -0
  30. package/dist/csv/records.d.ts +10 -0
  31. package/dist/csv/records.js +80 -0
  32. package/dist/csv/text.cjs +22 -0
  33. package/dist/csv/text.d.cts +8 -0
  34. package/dist/csv/text.d.ts +8 -0
  35. package/dist/csv/text.js +19 -0
  36. package/dist/csv/write.cjs +75 -0
  37. package/dist/csv/write.d.cts +22 -0
  38. package/dist/csv/write.d.ts +22 -0
  39. package/dist/csv/write.js +71 -0
  40. package/dist/edit/odg/scaffold.js +8 -8
  41. package/dist/edit/odp/scaffold.js +8 -8
  42. package/dist/edit/ods/scaffold.js +8 -8
  43. package/dist/edit/odt/scaffold.js +8 -8
  44. package/dist/index.cjs +48 -1
  45. package/dist/index.d.cts +13 -5
  46. package/dist/index.d.ts +13 -5
  47. package/dist/index.js +13 -5
  48. package/dist/layout/reconstruct.cjs +1 -1
  49. package/dist/layout/reconstruct.js +1 -1
  50. package/dist/metadata/write.cjs +2 -0
  51. package/dist/metadata/write.js +2 -0
  52. package/dist/model/bytes.cjs +7 -0
  53. package/dist/model/bytes.d.cts +3 -1
  54. package/dist/model/bytes.d.ts +3 -1
  55. package/dist/model/bytes.js +6 -1
  56. package/dist/odb/csv.cjs +3 -6
  57. package/dist/odb/csv.js +3 -6
  58. package/dist/svg/diagnostics.cjs +19 -0
  59. package/dist/svg/diagnostics.d.cts +10 -0
  60. package/dist/svg/diagnostics.d.ts +10 -0
  61. package/dist/svg/diagnostics.js +18 -0
  62. package/dist/svg/paint.cjs +817 -0
  63. package/dist/svg/paint.d.cts +19 -0
  64. package/dist/svg/paint.d.ts +19 -0
  65. package/dist/svg/paint.js +814 -0
  66. package/dist/svg/path.cjs +337 -0
  67. package/dist/svg/path.d.cts +22 -0
  68. package/dist/svg/path.d.ts +22 -0
  69. package/dist/svg/path.js +336 -0
  70. package/dist/svg/read.cjs +677 -0
  71. package/dist/svg/read.d.cts +12 -0
  72. package/dist/svg/read.d.ts +12 -0
  73. package/dist/svg/read.js +675 -0
  74. package/dist/svg/text.cjs +22 -0
  75. package/dist/svg/text.d.cts +8 -0
  76. package/dist/svg/text.d.ts +8 -0
  77. package/dist/svg/text.js +19 -0
  78. package/dist/svg/transform.cjs +206 -0
  79. package/dist/svg/transform.d.cts +23 -0
  80. package/dist/svg/transform.d.ts +23 -0
  81. package/dist/svg/transform.js +197 -0
  82. package/dist/svg/units.cjs +47 -0
  83. package/dist/svg/units.d.cts +12 -0
  84. package/dist/svg/units.d.ts +12 -0
  85. package/dist/svg/units.js +44 -0
  86. package/dist/svg/write.cjs +127 -0
  87. package/dist/svg/write.d.cts +23 -0
  88. package/dist/svg/write.d.ts +23 -0
  89. package/dist/svg/write.js +123 -0
  90. package/dist/xml/odf-text.js +2 -2
  91. package/package.json +1 -1
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![GitHub](https://img.shields.io/badge/GitHub-181717?logo=github&logoColor=white)](https://github.com/ExaDev/documents.js) [![npm](https://img.shields.io/badge/npm-CB3837?logo=npm&logoColor=white)](https://www.npmjs.com/package/documents.js) [![Release](https://img.shields.io/github/v/release/ExaDev/documents.js)](https://github.com/ExaDev/documents.js/releases/latest) [![CI](https://img.shields.io/github/actions/workflow/status/ExaDev/documents.js/ci.yml?branch=main)](https://github.com/ExaDev/documents.js/actions)
4
4
 
5
- > Converts between any two compatible document formats through a shared content/layout pivot. docx, pptx, odt, odp, ods, odg, xlsx, and markdown all read into and build from the same `ContentDocument`/`LayoutDocument` model, with PDF as the one format every variant can reach. A composition engine (`convertDocument`) routes 73 (source, target) pairs across the eight content formats and PDF, including fourteen PDF-pivot round trips, sixteen cross-format bridges (same-variant direct copies, cross-variant semantic transforms, and PDF-composed), plus special-case conversions for `.odm` master documents, `.odb` database front-ends (HSQLDB and Firebird, four storage tiers), standalone `.odf` formula documents, and a bounded SQL/rpt-formula engine for `.odb` reports. Also includes: read-and-write live-view editors for all six editable formats, docx comment/footnote/header-footer exposure via `readDocxExtras`, real font resolution (source-embedded faces ahead of caller-supplied, vendored substitutes, and the standard 14), a hand-written MathML typesetting engine with embedded-font PDF rendering and a matching MathML ⇄ OMML translator, and a fully hand-written PDF codec. Built on [ooxml.js](https://github.com/ExaDev/ooxml.js), [odf.js](https://github.com/ExaDev/odf.js), [pdf-codec](https://github.com/ExaDev/pdf-codec), [markdown-codec](https://github.com/ExaDev/markdown-codec), and [document-schema.js](https://github.com/ExaDev/document-schema.js).
5
+ > Converts between any two compatible document formats through a shared content/layout pivot. docx, pptx, odt, odp, ods, odg, xlsx, csv (TSV is the same format with a tab delimiter), svg, and markdown all read into and build from the same `ContentDocument`/`LayoutDocument` model, with PDF as the one format every variant can reach. A composition engine (`convertDocument`) routes 111 (source, target) pairs across the ten content formats and PDF, including twenty PDF-pivot round trips (the eight layout-engine formats, plus xlsx and csv composing through ods), twenty-four cross-format bridge functions (same-variant direct copies, cross-variant semantic transforms, and PDF-composed), plus special-case conversions for `.odm` master documents, `.odb` database front-ends (HSQLDB and Firebird, four storage tiers), standalone `.odf` formula documents, and a bounded SQL/rpt-formula engine for `.odb` reports. Also includes: read-and-write live-view editors for all six editable formats, docx comment/footnote/header-footer exposure via `readDocxExtras`, real font resolution (source-embedded faces ahead of caller-supplied, vendored substitutes, and the standard 14), a hand-written MathML typesetting engine with embedded-font PDF rendering and a matching MathML ⇄ OMML translator, and a fully hand-written PDF codec. Built on [ooxml.js](https://github.com/ExaDev/ooxml.js), [odf.js](https://github.com/ExaDev/odf.js), [pdf-codec](https://github.com/ExaDev/pdf-codec), [markdown-codec](https://github.com/ExaDev/markdown-codec), and [document-schema.js](https://github.com/ExaDev/document-schema.js).
6
6
 
7
7
  `documents.js` extends `ooxml.js` in two directions `ooxml.js` deliberately does not cover: full PDF support (parsing and generating, via `pdf-codec`), and a read-**and-write** manipulation API for docx/pptx content — `ooxml.js`'s own typed readers are one-way. The PDF codec is hand-written against ISO 32000-1, with no external PDF library as a dependency — see [Fidelity](#fidelity) and pdf-codec's own README for the honest trade-off (not as robust against adversarial PDFs as a 15+-year-hardened library; fully auditable and dependency-free instead). `src/mathml/` (the MathML typesetting engine) stays in this package and is hand-written too, for the same supply-chain reason.
8
8
 
@@ -72,7 +72,7 @@ npm install documents.js
72
72
 
73
73
  ### The generic entry point: `convertDocument`
74
74
 
75
- A single function, `convertDocument`, sits behind every named conversion and reaches every pair the composition engine can route — all 73 supported (source, target) combinations. The named functions below are thin one-line forwarders to it; they remain the ergonomic layer for a caller who wants a fixed pair and autocomplete discovery, while `convertDocument` is the first-class entry point for a caller working from a runtime format pair (CLI, MCP tool, matrix enumeration).
75
+ A single function, `convertDocument`, sits behind every named conversion and reaches every pair the composition engine can route — all 111 supported (source, target) combinations. The named functions below are thin one-line forwarders to it; they remain the ergonomic layer for a caller who wants a fixed pair and autocomplete discovery, while `convertDocument` is the first-class entry point for a caller working from a runtime format pair (CLI, MCP tool, matrix enumeration).
76
76
 
77
77
  ```ts
78
78
  import { convertDocument } from 'documents.js';
@@ -89,10 +89,10 @@ const odtBytes = convertDocument('docx', 'odt', docxBytes, { onMathDiagnostic: (
89
89
 
90
90
  ### PDF-pivot conversions
91
91
 
92
- The fourteen round-trip ergonomic conversions between the formats with their own layout engine and PDF (docx/pptx/odt/odp/ods/odg/markdown ⇄ PDF, all round-tripping both ways), plus `xlsxToPdf`/`pdfToXlsx` (composing the ods⇄xlsx bridge with the ods⇄pdf layout pair internally):
92
+ The sixteen round-trip ergonomic conversions between the formats with their own layout engine and PDF (docx/pptx/odt/odp/ods/odg/markdown/svg ⇄ PDF, all round-tripping both ways), plus `xlsxToPdf`/`pdfToXlsx` and `csvToPdf`/`pdfToCsv` (each composing its ods bridge with the ods⇄pdf layout pair internally — neither xlsx nor csv has a layout engine of its own):
93
93
 
94
94
  ```ts
95
- import { docxToPdf, markdownToPdf, odgToPdf, odpToPdf, odsToPdf, odtToPdf, pdfToDocx, pdfToMarkdown, pdfToOdg, pdfToOdp, pdfToOds, pdfToOdt, pdfToPptx, pdfToXlsx, pptxToPdf, xlsxToPdf } from 'documents.js';
95
+ import { csvToPdf, docxToPdf, markdownToPdf, odgToPdf, odpToPdf, odsToPdf, odtToPdf, pdfToCsv, pdfToDocx, pdfToMarkdown, pdfToOdg, pdfToOdp, pdfToOds, pdfToOdt, pdfToPptx, pdfToSvg, pdfToXlsx, pptxToPdf, svgToPdf, xlsxToPdf } from 'documents.js';
96
96
 
97
97
  const pdfBytes = docxToPdf(docxBytes);
98
98
  const docxBytes2 = pdfToDocx(pdfBytes);
@@ -117,13 +117,19 @@ const xlsxBytes2 = pdfToXlsx(pdfFromXlsx); // composes pdfToOds -> odsToXlsx int
117
117
 
118
118
  const pdfFromMarkdown = markdownToPdf(markdownBytes);
119
119
  const markdownBytes2 = pdfToMarkdown(pdfFromMarkdown); // the lossiest conversion in the whole package -- see Fidelity
120
+
121
+ const pdfFromCsv = csvToPdf(csvBytes); // composes csvToOds -> odsToPdf internally
122
+ const csvBytes2 = pdfToCsv(pdfFromCsv); // composes pdfToOds -> odsToCsv internally; recovers what was printed, then heuristically re-types it
123
+
124
+ const pdfFromSvg = svgToPdf(svgBytes); // reads the six shape primitives into a drawing ContentDocument, then the same drawing layout engine odgToPdf feeds renders it
125
+ const svgBytes2 = pdfToSvg(pdfFromSvg); // readPdf -> reconstructDrawing -> buildSvgText: vector geometry recovers near-1:1, while recovered text boxes sit outside the svg writer's vector-only scope (reported per shape, never silently dropped)
120
126
  ```
121
127
 
122
128
  Each accepts an optional `signal` (`AbortSignal`) and either `onSubstitution` (X → PDF, called per character not representable in a standard-14 font) or `sink` (PDF → X, called per recoverable parse diagnostic). Every X → PDF conversion additionally accepts `fonts` (extra `ProvidedFont` faces) and `onFontSubstitution` (per family+weight+style that resolved to something else). Neither is needed for the common case — see [Fonts](#fonts).
123
129
 
124
130
  ### Cross-format bridges
125
131
 
126
- Sixteen bridge functions across eight pairs bypass the PDF pivot entirely. Five same-variant direct-copy pairs (`odtToDocx`/`docxToOdt`, `odpToPptx`/`pptxToOdp`, `odsToXlsx`/`xlsxToOds`, `markdownToDocx`/`docxToMarkdown`, `markdownToOdt`/`odtToMarkdown`) compose a direct `readXContent` → `buildYPackage` pivot copy. Two cross-variant semantic-transform pairs (`docxToPptx`/`pptxToDocx`, `odtToOdp`/`odpToOdt`) go through `src/convert/variant-bridges.ts`. One PDF-composed pair (`xlsxToMarkdown`/`markdownToXlsx`) routes through PDF internally — the single lossiest conversion in the package.
132
+ Twenty-four bridge functions across twelve pairs bypass the PDF pivot where a direct path exists. Eight same-variant direct-copy pairs (`odtToDocx`/`docxToOdt`, `odpToPptx`/`pptxToOdp`, `odsToXlsx`/`xlsxToOds`, `csvToOds`/`odsToCsv`, `csvToXlsx`/`xlsxToCsv`, `svgToOdg`/`odgToSvg`, `markdownToDocx`/`docxToMarkdown`, `markdownToOdt`/`odtToMarkdown`) compose a direct `readXContent` → `buildYPackage` pivot copy — the csv pairs are one hop to its spreadsheet siblings, so csv never needs PDF to reach ods or xlsx, and `svgToOdg`/`odgToSvg` bridge svg to its drawing sibling odg the same way. Two cross-variant semantic-transform pairs (`docxToPptx`/`pptxToDocx`, `odtToOdp`/`odpToOdt`) go through `src/convert/variant-bridges.ts`. Two PDF-composed pairs (`xlsxToMarkdown`/`markdownToXlsx`, `csvToMarkdown`/`markdownToCsv`) route through PDF internally — the lossiest conversions in the package.
127
133
 
128
134
  ```ts
129
135
  import { odtToDocx, docxToOdt, markdownToDocx, docxToMarkdown } from 'documents.js';
@@ -135,7 +141,7 @@ const docxFromMarkdown = markdownToDocx(markdownBytes);
135
141
  const markdownBytes3 = docxToMarkdown(docxFromMarkdown); // colour, font family/size, and explicit alignment have no markdown source construct -- dropped on this hop
136
142
  ```
137
143
 
138
- Each takes an optional `{ signal }` — no `onSubstitution`/`sink`, since there is no font substitution or PDF-parse degradation. `odtToDocx`/`markdownToDocx`/`docxToOdt`/`docxToMarkdown` additionally take `onMathDiagnostic`, called per formula construct that degraded crossing the bridge.
144
+ Each takes an optional `{ signal }` — no `onSubstitution`/`sink`, since there is no font substitution or PDF-parse degradation. `odtToDocx`/`markdownToDocx`/`docxToOdt`/`docxToMarkdown` additionally take `onMathDiagnostic`, called per formula construct that degraded crossing the bridge. The csv-sourced bridges (`csvToOds`, `csvToXlsx`, `csvToMarkdown`, `csvToPdf`) take `{ delimiter }` — `'\t'` parses the same format as TSV, since a delimiter is a parse option, not a different document format — and `onCellTypeInference`, the per-decision audit channel the read shares with `pdfToOds`. The csv-target bridges (`odsToCsv`, `xlsxToCsv`, `markdownToCsv`, `pdfToCsv`) take `{ delimiter, sheet }`: csv has no second sheet, so writing a multi-sheet source refuses with `CsvSheetNotSpecifiedError` naming every sheet until a caller selects one. The svg-sourced bridges (`svgToOdg`, `svgToPdf`) take `onSvgDiagnostic`, the reader's per-scope-limit channel; the svg-target bridges (`odgToSvg`, `pdfToSvg`) take `{ page, onSvgDiagnostic }`: an svg is a single drawing, so writing a multi-page source refuses with `SvgMultiPageNotSpecifiedError` naming the page count until `{ page }` selects one (an index, because drawing pages are anonymous where sheets are named).
139
145
 
140
146
  ### The `DocumentConverter` port
141
147
 
@@ -151,12 +157,12 @@ const { document, diagnostics } = await converter.convert(
151
157
  );
152
158
  ```
153
159
 
154
- `DocumentFormat` includes `docx`/`pptx`/`xlsx`/`odt`/`odp`/`ods`/`odg`/`odf`/`markdown`/`pdf` — ten members. The port's `conversions` list is derived from `resolveCompositionPlan` plus the `odf`→`pdf` special case — 73 pairs total. `DocumentFormat` is inferred from `DocumentFormatSchema` (a real Zod schema); `DOCUMENT_FORMATS` is exported as a plain array derived from the same schema:
160
+ `DocumentFormat` includes `docx`/`pptx`/`xlsx`/`odt`/`odp`/`ods`/`odg`/`svg`/`odf`/`csv`/`markdown`/`pdf` — twelve members. The port's `conversions` list is derived from `resolveCompositionPlan` plus the `odf`→`pdf` special case — 111 pairs total. `DocumentFormat` is inferred from `DocumentFormatSchema` (a real Zod schema); `DOCUMENT_FORMATS` is exported as a plain array derived from the same schema:
155
161
 
156
162
  ```ts
157
163
  import { DOCUMENT_FORMATS, DocumentFormatSchema } from 'documents.js';
158
164
 
159
- console.log(DOCUMENT_FORMATS); // ['docx', 'pptx', 'xlsx', 'odt', 'odp', 'ods', 'odg', 'odf', 'markdown', 'pdf']
165
+ console.log(DOCUMENT_FORMATS); // ['docx', 'pptx', 'xlsx', 'odt', 'odp', 'ods', 'odg', 'svg', 'odf', 'csv', 'markdown', 'pdf']
160
166
  DocumentFormatSchema.parse(userSuppliedFormat); // throws a ZodError for anything outside that list
161
167
  ```
162
168
 
@@ -202,7 +208,7 @@ const docxBytesAgain = buildDocumentBytes(captured, 'docx');
202
208
 
203
209
  ### Package decode/encode, metadata, and deep imports
204
210
 
205
- `decodeDocumentPackage`/`encodeDocumentPackage` dispatch docx/pptx/xlsx through `ooxml.js`'s OPC codec and odt/odp/ods/odg/odf through `odf.js`'s ODF codec, throwing `UnsupportedPackageFormatError` for `markdown`/`pdf`. `decodeOdbPackage` is the `.odb`-specific sibling (`.odb` is not a `DocumentFormat` member):
211
+ `decodeDocumentPackage`/`encodeDocumentPackage` dispatch docx/pptx/xlsx through `ooxml.js`'s OPC codec and odt/odp/ods/odg/odf through `odf.js`'s ODF codec, throwing `UnsupportedPackageFormatError` for `markdown`/`csv`/`svg`/`pdf` (none of the four is a package — the first three are plain text, pdf is bytes). `decodeOdbPackage` is the `.odb`-specific sibling (`.odb` is not a `DocumentFormat` member):
206
212
 
207
213
  ```ts
208
214
  import { decodeDocumentPackage, decodeOdbPackage, encodeDocumentPackage } from 'documents.js';
@@ -212,7 +218,7 @@ const docxBytesAgain = encodeDocumentPackage('docx', pkg);
212
218
  const odbPkg = decodeOdbPackage(odbBytes);
213
219
  ```
214
220
 
215
- `readDocumentMetadata`/`setDocumentMetadata` read or patch metadata across any `DocumentFormat`. `setDocumentMetadata` patches in place (source/target formats must match); `odf` is rejected in both directions. `readDocumentMetadata('xlsx', ...)` is a named exception: it renders via `xlsxToPdf` and reads the PDF's metadata, because a direct read and the PDF-preview path genuinely disagree on `createdIso`/`modifiedIso`/`producer`.
221
+ `readDocumentMetadata`/`setDocumentMetadata` read or patch metadata across any `DocumentFormat`. `setDocumentMetadata` patches in place (source/target formats must match); `odf` is rejected in both directions, and `csv` is rejected in both directions too (RFC 4180 text has no metadata container) — `readDocumentMetadata('csv', ...)` answers an empty `LayoutMetadata` for the same reason. `svg` reads its root `<title>` as `metadata.title` and is rejected as a `setDocumentMetadata` source/target for the mirror-image reason: `<title>` is svg's whole metadata surface, so any other override would be silently dropped by the rebuild. `readDocumentMetadata('xlsx', ...)` is a named exception: it renders via `xlsxToPdf` and reads the PDF's metadata, because a direct read and the PDF-preview path genuinely disagree on `createdIso`/`modifiedIso`/`producer`.
216
222
 
217
223
  ```ts
218
224
  import { readDocumentMetadata, setDocumentMetadata } from 'documents.js';
@@ -230,7 +236,7 @@ import { buildOdtPackage } from 'documents.js/edit/odt/content';
230
236
 
231
237
  ### Reading and building xlsx content directly
232
238
 
233
- Every other content format has its own standalone `readXContent`-shaped entry point (`readDocxContent`, `readPptxContent`, `readOdtContent`, `readOdpContent`, `readOdsContent`, `readOdgContent`) — xlsx is no longer the exception. `readXlsxContent`/`buildXlsxPackage` are `ooxml.js`'s own spreadsheet `ContentDocument` read/build pair — the same one the `ods⇄xlsx` bridge and every xlsx metadata-rebuild path already use internally — re-exported here directly rather than wrapped, since `readXlsxContent` already produces the right shape on its own:
239
+ Every other content format has its own standalone `readXContent`-shaped entry point (`readDocxContent`, `readPptxContent`, `readOdtContent`, `readOdpContent`, `readOdsContent`, `readOdgContent`) — xlsx is no longer the exception. `readXlsxContent`/`buildXlsxPackage` are `ooxml.js`'s own spreadsheet `ContentDocument` read/build pair — the same one the `ods⇄xlsx` bridge and every xlsx metadata-rebuild path already use internally — re-exported here directly rather than wrapped, since `readXlsxContent` already produces the right shape on its own. csv's `readCsvContent`/`buildCsvText` are the same kind of directly-exported stage pair, one level further in: they operate on RFC 4180 text rather than a decoded package (see `src/csv/` under Architecture). svg's `readSvgContent`/`buildSvgText` are the drawing-variant counterpart of csv's pair, operating on SVG text rather than a decoded package (see `src/svg/` under Architecture).
234
240
 
235
241
  ```ts
236
242
  import { buildXlsxPackage, decodeDocumentPackage, encodeDocumentPackage, readXlsxContent } from 'documents.js';
@@ -326,7 +332,7 @@ const layout = readPdf(pdfBytes); // -> LayoutDocument: pages of positioned text
326
332
  const bytes = writePdf(layout);
327
333
  ```
328
334
 
329
- The nine PDF round trips and ten PDF-bypassing bridges are also available as schema-validated [`z.codec()`](https://zod.dev) pairs (`pdfCodec`, `docxPdfCodec`, `pptxPdfCodec`, `odtPdfCodec`, `odpPdfCodec`, `odsPdfCodec`, `odgPdfCodec`, `xlsxPdfCodec`, `markdownPdfCodec`, `odtDocxCodec`, `odpPptxCodec`, `odsXlsxCodec`, `markdownDocxCodec`, `markdownOdtCodec`) — the no-options form, adding automatic two-way schema validation:
335
+ The eleven PDF round trips and sixteen PDF-bypassing bridge directions are also available as schema-validated [`z.codec()`](https://zod.dev) pairs (`pdfCodec`, `docxPdfCodec`, `pptxPdfCodec`, `odtPdfCodec`, `odpPdfCodec`, `odsPdfCodec`, `odgPdfCodec`, `svgPdfCodec`, `xlsxPdfCodec`, `csvPdfCodec`, `markdownPdfCodec`, `odtDocxCodec`, `odpPptxCodec`, `odsXlsxCodec`, `odsCsvCodec`, `xlsxCsvCodec`, `odgSvgCodec`, `markdownDocxCodec`, `markdownOdtCodec`) — the no-options form, adding automatic two-way schema validation. The two PDF-composed pairs have codec forms too (`xlsxMarkdownCodec`, `csvMarkdownCodec`):
330
336
 
331
337
  ```ts
332
338
  import { z } from 'zod';
@@ -504,6 +510,8 @@ The package is layered from generic primitives outward to the two conversion dir
504
510
  - **`src/ooxml/`** — thin adapters over `ooxml.js`'s own `readDocx`/`readPptx`, wrapping results into `ContentDocument`. `docx/formula.ts` is the one local reading pass (splicing OOXML math equations). `docx/extras.ts`'s `readDocxExtras` returns comments/footnotes/headers/footers/numbering.
505
511
  - **`src/odf/`** — ODF-side counterparts: `readOdtContent`/`readOdpContent`/`readOdsContent`/`readOdgContent` are thin adapters over `odf.js`. `formula/read.ts`/`formula/detect.ts` handle embedded formula detection (genuinely new work with no `odf.js`-side equivalent).
506
512
  - **`src/markdown/`** — third adapter family, via `markdown-codec`. `readMarkdownContent` passes `readMarkdown`'s result straight through (it already produces a full `ContentDocument`). `buildMarkdownText` wraps `writeMarkdown`. `text.ts` is the byte↔text boundary. `MarkdownEditor` holds a mutable in-memory `ContentDocument`.
513
+ - **`src/csv/`** — fourth adapter family, sharing the spreadsheet variant with xlsx/ods. `records.ts` is the RFC 4180 record parser/writer (one shared `quoteCsvField`, also used by the `.odb` CSV exporter); `text.ts` is the byte↔text boundary, rejecting malformed UTF-8; `read.ts` turns records into a spreadsheet `ContentDocument` (first record as verbatim string header, data cells through the same cell-typing heuristic `pdfToOds` uses); `write.ts` turns one sheet of a spreadsheet `ContentDocument` back into records via each cell's `displayText`. TSV is the same format with `{ delimiter: '\t' }` on either side.
514
+ - **`src/svg/`** — fifth adapter family, sharing the drawing variant with odg. `text.ts` is the byte↔text boundary, rejecting malformed UTF-8; `read.ts` maps the six SVG shape primitives (rect/circle/ellipse/line/polyline/polygon/path) onto a one-page drawing `ContentDocument`, with transform lists composed as 2×3 affines and CSS lengths and the viewBox map resolved into page points; `write.ts` writes the six primitives back out, one shape element each; `path.ts` is the full SVG path-data grammar (M/L/H/V/C/S/Z plus Q/T/A and the relative forms — S/Q/T convert exactly, A is the one bounded approximation at ≤90° per cubic); `transform.ts` parses and composes the transform attribute and classifies the result by frame representability; `units.ts` resolves CSS length units and the viewBox; `paint.ts` resolves fill/stroke presentation attributes and dash styles; `diagnostics.ts` is the shared scope-limit vocabulary.
507
515
  - **`src/layout/`** — the pure conversion algorithms: `engine.ts` (wordprocessing → layout: flow, line-breaking, pagination), `slides.ts` (presentation → layout: direct placement), `sheets.ts` (spreadsheet → layout: grid, print settings, the first algorithm accepting `AbortSignal`), `drawing.ts` (drawing → layout: vector primitives + shape reuse), `reconstruct.ts` (layout → content: baseline clustering for wordprocessing/presentation, near-1:1 mapping for drawing, gridline-lattice-or-text-clustering for spreadsheet).
508
516
  - **`src/hsqldb/`** — `.odb` decoders, four tiers: `script.ts` (TEXT-script DDL/DML parser), `rowformat.ts`/`cache.ts` (CACHED binary row-store), `binary-script.ts` (BINARY/COMPRESSED whole-script). All import only `document-schema.js` — no odf.js knowledge.
509
517
  - **`src/firebird/`** — Tier 3: gbak logical-backup reader. `reader.ts` (attribute framing + RLE decompression + XDR decoding), `schema.ts`/`data.ts` (table/row walking). No ratified spec — built against Firebird's own engine source.
@@ -550,8 +558,16 @@ To run a single test file: `pnpm vitest run src/path/to/file.test.ts`.
550
558
  - **ODF text getters must call `decodeOdfText`.** See the dedicated gotcha above.
551
559
  - **`readPdf` recovers rect/ellipse/line as their own `LayoutRect`/`LayoutEllipse`/`LayoutLine` kinds** via pdf-codec's shape-pattern detection — an axis-aligned closed four-corner subpath is a rect, four kappa-ratio cubics at cardinal points is an ellipse, an open single straight stroke is a line. A false positive changes kind, never geometry. Off-axis rotations, freeform curves, and multi-subpath figures narrow to `LayoutPath`.
552
560
  - **`pdfToOds` re-types cells heuristically — this is probabilistic, not a fidelity guarantee.** A rendered PDF never carries a cell's typed value, only the printed string. Re-typing fires only where the string has exactly one defensible reading: the decimal must be exactly representable as a JS number; separators must be unambiguous (`"1,234"` is declined — competing European reading is 1.234); leading zeros decline (`"007"`); dates must self-state their component roles (ISO or named month accepted; `"01/02/2024"` declined). `TRUE`/`FALSE` re-type as booleans; `Yes`/`No` are declined. `displayText` always carries the rendered string verbatim. `onCellTypeInference` reports every decision. A formula is never claimed.
561
+ - **The csv read shares `pdfToOds`'s cell-typing heuristic, with the same decision-only audit channel.** The first record is a verbatim string header (never re-typed, even when it looks like data); data cells re-type through `inferCellValue` exactly as the PDF reconstructor does — declines keep the plain string, `displayText` always carries the raw field text, and `onCellTypeInference` fires per decision, staying silent for header cells and no-candidate text. The parser drops blank records, so a record of one empty field alone cannot round-trip. Writing csv takes exactly one sheet: a multi-sheet source refuses with `CsvSheetNotSpecifiedError` naming every sheet until `{ sheet }` selects one. TSV is not a separate format — `{ delimiter: '\t' }` on either side parses or writes the same grid.
562
+ - **The svg read's scope limits are named diagnostics, never silent drops.** Text, images, `use` references, gradients/patterns, CSS style blocks, and out-of-scope opacity are each reported through `onSvgDiagnostic` with a code from `SVG_DIAGNOSTIC_CODES` (`svg/text-unsupported`, `svg/image-unsupported`, `svg/use-unsupported`, `svg/gradient-unsupported`, `svg/css-style-ignored`, `svg/opacity-ignored`, …) — the same contract as markdown's construct-mapping vocabulary. A plain vector SVG (the six shape primitives, transforms, paint) reads silently.
563
+ - **An absent SVG fill paints black — the SVG spec default, and the one visible svg⇄odg asymmetry.** The svg reader turns a missing `fill` attribute into a black fill; the svg writer leaves the drawing frame's absent fill unset rather than second-guessing it. Round-tripping odg→svg→odg therefore converts an unfilled odg shape into a black-filled one, mirroring what a browser would render from the same markup.
564
+ - **A rootless size falls back to the CSS default, and a stretched viewBox says so.** When neither `width`/`height` nor a `viewBox` is present, the read assumes the CSS default 300×150px viewport ({225, 112.5}pt) and reports `svg/default-size-assumed`; when `width`/`height` and the viewBox disagree in aspect ratio, the read maps through the stretched viewport and reports `svg/preserve-aspect-ratio-stretched` rather than silently re-proportioning the geometry.
565
+ - **Writing svg takes exactly one page.** An svg is a single drawing, so a multi-page source refuses with `SvgMultiPageNotSpecifiedError` naming the page count until `{ page }` selects one (an index, because drawing pages are anonymous where csv's sheets are named — the same contract one variant over).
566
+ - **svg→csv and svg→markdown honestly produce empty output.** The svg read has no text in scope, and neither csv nor markdown has a vocabulary for vectors, so the composition routes (via PDF into the spreadsheet/text readers) yield a document with nothing to emit — pinned as expected-empty in the round-trip matrix rather than dressed up as a conversion.
567
+ - **A rotated rect or ellipse stays a frame, with `rotationDeg`.** The read composes the transform list into one 2×3 affine and classifies it: an axis-aligned map (any scale, mirrors included) folds into the frame; a similarity rotation keeps the frame and records `rotationDeg` about the frame's centre; a shear or rotation-composed non-uniform scale narrows to a path. The affine itself is exact in every case — only which container carries it changes.
568
+ - **The path grammar's one approximation is the elliptical arc.** `A` converts endpoint-to-centre parameterisation exactly (F.6.5, with the F.6.5.6 radii correction), then approximates each arc segment with kappa-bounded cubics at ≤90° per cubic; S/Q/T convert exactly (a quadratic elevates to an exact cubic, T reflects the previous quadratic's own control).
553
569
  - **`reconstructWordprocessing`/`reconstructPresentation` recover vector primitives too**, in a nested drawing document — a rule under a heading, an underline, a cell background are all recovered as vectors (intended — discarding real content because it might be incidental is ruled out). A table's gridlines are excluded from vector recovery when the lattice claims them.
554
- - **Recovered vectors round-trip through all four readers** — `buildDocxPackage`/`buildPptxPackage` write real DrawingML; `buildOdtPackage`/`buildOdpPackage` write real `draw:rect`/`draw:ellipse`/`draw:line`/`draw:path`. The six PDF-bypassing bridges carry vector geometry across too.
570
+ - **Recovered vectors round-trip through all five vector-writing readers** — `buildDocxPackage`/`buildPptxPackage` write real DrawingML; `buildOdtPackage`/`buildOdpPackage` write real `draw:rect`/`draw:ellipse`/`draw:line`/`draw:path`; `buildSvgText` writes real SVG shape elements. The PDF-bypassing bridges between vector-carrying formats (odt⇄docx, odp⇄pptx, odt⇄odp, svg⇄odg) carry vector geometry across too.
555
571
  - **Each format wraps a vector shape differently.** OOXML: pptx gets a plain `p:sp`; docx gets a `w:drawing`/`wp:anchor` with `behindDoc="1"`/`wp:wrapNone` carrying a `wps:wsp`. ODF: odp appends to `draw:page`; odt anchors in a `text:p` with `style:horizontal-rel`/`style:vertical-rel="page"` (page-absolute coordinates) and `style:run-through="background"`.
556
572
  - **`ContentStroke.style` is not written by vector writers.** `LayoutLine`/`LayoutPath` carry the enum, but neither ODF nor DrawingML vector writers read it — a hand-built vector with `stroke.style` paints solid. Cell borders are a separate path that does set the style.
557
573
  - **`pdfToOds` recovers what was printed, not what was entered.** `reconstructSpreadsheet` tries a real gridline lattice first (`MIN_GRIDLINE_COUNT_PER_AXIS = 3`), using line positions directly as cell boundaries; absent one, clusters text into a grid from geometry. Column widths/row heights are measured, never invented. No print range/scale/repeat-rows/manual-breaks are inferred.
@@ -618,20 +634,22 @@ To run a single test file: `pnpm vitest run src/path/to/file.test.ts`.
618
634
 
619
635
  Read as **row → column**. `✓` lossless, `~` bounded, `✗` lossy, `✗✗` severe, `→` one-way, `–` no conversion. `.odm`/`.odb` sit outside this table.
620
636
 
621
- | ↓ from \ to → | docx | pptx | xlsx | odt | odp | ods | odg | odf | markdown | pdf |
622
- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
623
- | **docx** | — | ~ | – | ✓ | – | – | – | – | ✗ | ~ |
624
- | **pptx** | ~ | — | – | – | ✓ | – | – | – | – | ~ |
625
- | **xlsx** | – | – | — | – | – | ~ | – | – | ✗✗ | ~ |
626
- | **odt** | ✓ | – | – | — | ~ | – | – | – | ✗ | ~ |
627
- | **odp** | – | ✓ | – | ~ | — | – | – | – | – | ~ |
628
- | **ods** | – | – | ~ | – | – | — | – | – | – | ~ |
629
- | **odg** | – | – | – | – | – | – | — | – | – | ~ |
630
- | **odf** | | | | | | | | — | – | |
631
- | **markdown** | ~ | – | ✗✗ | ~ | – | – | – | – | — | ~ |
632
- | **pdf** | | | | | | | | – | ✗✗ | |
633
-
634
- 73 of 90 directional pairs are routable. The `ContentDocument`/`LayoutDocument` pivots are the hub, not PDF fourteen bridges bypass PDF entirely.
637
+ | ↓ from \ to → | docx | pptx | xlsx | odt | odp | ods | odg | svg | odf | markdown | csv | pdf |
638
+ | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
639
+ | **docx** | — | ~ | – | ✓ | – | – | – | ✗ | – | ✗ | ✗ | ~ |
640
+ | **pptx** | ~ | — | – | – | ✓ | – | – | ✗ | – | – | ✗ | ~ |
641
+ | **xlsx** | – | – | — | – | – | ~ | – | ✗ | – | ✗✗ | ~ | ~ |
642
+ | **odt** | ✓ | – | – | — | ~ | – | – | ✗ | – | ✗ | ✗ | ~ |
643
+ | **odp** | – | ✓ | – | ~ | — | – | – | ✗ | – | – | ✗ | ~ |
644
+ | **ods** | – | – | ~ | – | – | — | – | ✗ | – | – | ~ | ~ |
645
+ | **odg** | – | – | – | – | – | – | — | ✓ | – | – | ✗ | ~ |
646
+ | **svg** | | | | | | | | — | – | ✗✗ | ✗✗ | ~ |
647
+ | **odf** | | – | | | – | – | – | – | — | | – | → |
648
+ | **markdown** | ~ | | ✗✗ | ~ | | | | ✗✗ | – | — | ✗✗ | ~ |
649
+ | **csv** | ✗ | ✗ | ✓ | ✗ | ✗ | ✓ | ✗ | ✗ | – | ✗✗ | — | ~ |
650
+ | **pdf** | | | | | | | | | | ✗✗ | ✗ | — |
651
+
652
+ 111 of 132 directional pairs are routable. The `ContentDocument`/`LayoutDocument` pivots are the hub, not PDF — twenty bridges bypass PDF entirely.
635
653
 
636
654
  **X → PDF** is a genuine layout render: positioned text, images, tables, lists, vector primitives, styled through the full cascade. It is a faithful visual approximation, not pixel-identical — closeness depends on font availability.
637
655
 
@@ -641,11 +659,13 @@ Read as **row → column**. `✓` lossless, `~` bounded, `✗` lossy, `✗✗` s
641
659
 
642
660
  **PDF → odg** is near-1:1 mapping (no clustering needed). Kind narrows upstream: rotated rects, freeform curves, multi-subpath figures become `path`.
643
661
 
662
+ **svg ⇄ PDF and PDF → svg** lay out through the same drawing engine odg feeds, so `svgToPdf` is bounded only by the svg read's documented scope; `pdfToSvg` reuses `pdfToOdg`'s near-1:1 vector recovery writing SVG shape elements instead. Recovered text boxes sit outside the svg writer's vector-only scope — reported per shape via `onSvgDiagnostic`, never silently dropped — and svg→csv/svg→markdown honestly produce empty output (no text in the read's scope, no vector vocabulary in the target).
663
+
644
664
  **PDF → ods** recovers what was printed, not what was entered. The printed string always survives in `displayText`; re-typed `value` is explicitly probabilistic inference.
645
665
 
646
- **`markdownToPdf`/`pdfToMarkdown`** is the lossiest round trip: `markdownToPdf` is faithful, but `pdfToMarkdown` stacks reconstruction lossiness PLUS markdown's coarser vocabulary (no colour, font, size, alignment).
666
+ **`markdownToPdf`/`pdfToMarkdown`** is the lossiest round trip: `markdownToPdf` is faithful, but `pdfToMarkdown` stacks reconstruction lossiness PLUS markdown's coarser vocabulary (no colour, font, size, alignment). The PDF-composed markdown bridges (`xlsxToMarkdown`/`markdownToXlsx`, `csvToMarkdown`/`markdownToCsv`) stack the same two losses in both directions — hence their `✗✗` cells.
647
667
 
648
- **The first three bridge pairs** (odt⇄docx, odp⇄pptx, ods⇄xlsx) bypass PDF entirely — no layout engine, no reconstruction. Text, styling, tables, lists, rotated shapes survive completely. `ods⇄xlsx` has small format-boundary limits (time cells, formula dialects). Embedded formulas survive `odtToDocx` as real OOXML math.
668
+ **The six same-variant bridge pairs** (odt⇄docx, odp⇄pptx, ods⇄xlsx, csv⇄ods, csv⇄xlsx, svg⇄odg) bypass PDF entirely — no layout engine, no reconstruction. Text, styling, tables, lists, rotated shapes survive completely. `ods⇄xlsx` has small format-boundary limits (time cells, formula dialects). Embedded formulas survive `odtToDocx` as real OOXML math. The csv pairs are bounded by what csv itself carries: toward ods/xlsx nothing the csv had is lost, while writing to csv collapses each cell to its `displayText` — formulas become their rendered values, formatting disappears, and a multi-sheet source must name the sheet it wants. The svg pair carries the six vector primitives losslessly in both directions; its one asymmetry is paint defaults — SVG's absent-fill-is-black versus a drawing frame's no-fill.
649
669
 
650
670
  **The two markdown bridge pairs** bypass PDF too, but markdown's grammar has no construct for colour/font/size/alignment — `docxToMarkdown`/`odtToMarkdown` drop them (format-boundary loss, not approximation).
651
671
 
@@ -15,6 +15,12 @@ const require_odf_odp_read = require("../odf/odp/read.cjs");
15
15
  const require_odf_ods_read = require("../odf/ods/read.cjs");
16
16
  const require_odf_odg_read = require("../odf/odg/read.cjs");
17
17
  const require_markdown_text = require("../markdown/text.cjs");
18
+ const require_csv_text = require("../csv/text.cjs");
19
+ const require_csv_read = require("../csv/read.cjs");
20
+ const require_csv_write = require("../csv/write.cjs");
21
+ const require_svg_text = require("../svg/text.cjs");
22
+ const require_svg_read = require("../svg/read.cjs");
23
+ const require_svg_write = require("../svg/write.cjs");
18
24
  const require_ports_abort = require("../ports/abort.cjs");
19
25
  const require_package_codec = require("../package-codec.cjs");
20
26
  let ooxml_js = require("ooxml.js");
@@ -81,6 +87,14 @@ const DOCUMENT_FORMAT_CODECS = {
81
87
  }),
82
88
  write: (content) => require_markdown_text.encodeMarkdownText(require_markdown_write.buildMarkdownText(content))
83
89
  } },
90
+ csv: { content: {
91
+ read: (bytes) => require_csv_read.readCsvContent(require_csv_text.decodeCsvText(bytes)),
92
+ write: (content) => require_csv_text.encodeCsvText(require_csv_write.buildCsvText(content))
93
+ } },
94
+ svg: { content: {
95
+ read: (bytes) => require_svg_read.readSvgContent(require_svg_text.decodeSvgText(bytes)),
96
+ write: (content) => require_svg_text.encodeSvgText(require_svg_write.buildSvgText(content))
97
+ } },
84
98
  pdf: { layout: {
85
99
  read: (bytes, options) => (0, pdf_codec.readPdf)(requireArrayBufferBytes(bytes), { signal: options?.signal }),
86
100
  write: (layout, options) => (0, pdf_codec.writePdf)(layout, { signal: options?.signal })
@@ -14,6 +14,12 @@ import { readOdpContent } from "../odf/odp/read.js";
14
14
  import { readOdsContent } from "../odf/ods/read.js";
15
15
  import { readOdgContent } from "../odf/odg/read.js";
16
16
  import { decodeMarkdownText, encodeMarkdownText } from "../markdown/text.js";
17
+ import { decodeCsvText, encodeCsvText } from "../csv/text.js";
18
+ import { readCsvContent } from "../csv/read.js";
19
+ import { buildCsvText } from "../csv/write.js";
20
+ import { decodeSvgText, encodeSvgText } from "../svg/text.js";
21
+ import { readSvgContent } from "../svg/read.js";
22
+ import { buildSvgText } from "../svg/write.js";
17
23
  import { throwIfAborted } from "../ports/abort.js";
18
24
  import { decodeDocumentPackage, encodeDocumentPackage } from "../package-codec.js";
19
25
  import { buildXlsxPackage, readXlsxContent } from "ooxml.js";
@@ -80,6 +86,14 @@ const DOCUMENT_FORMAT_CODECS = {
80
86
  }),
81
87
  write: (content) => encodeMarkdownText(buildMarkdownText(content))
82
88
  } },
89
+ csv: { content: {
90
+ read: (bytes) => readCsvContent(decodeCsvText(bytes)),
91
+ write: (content) => encodeCsvText(buildCsvText(content))
92
+ } },
93
+ svg: { content: {
94
+ read: (bytes) => readSvgContent(decodeSvgText(bytes)),
95
+ write: (content) => encodeSvgText(buildSvgText(content))
96
+ } },
83
97
  pdf: { layout: {
84
98
  read: (bytes, options) => readPdf(requireArrayBufferBytes(bytes), { signal: options?.signal }),
85
99
  write: (layout, options) => writePdf(layout, { signal: options?.signal })
@@ -31,11 +31,21 @@ const FORMAT_CAPABILITIES = {
31
31
  variant: "spreadsheet",
32
32
  hasLayoutPath: false
33
33
  },
34
+ csv: {
35
+ format: "csv",
36
+ variant: "spreadsheet",
37
+ hasLayoutPath: false
38
+ },
34
39
  odg: {
35
40
  format: "odg",
36
41
  variant: "drawing",
37
42
  hasLayoutPath: true
38
43
  },
44
+ svg: {
45
+ format: "svg",
46
+ variant: "drawing",
47
+ hasLayoutPath: true
48
+ },
39
49
  odf: {
40
50
  format: "odf",
41
51
  variant: "formula",
@@ -30,11 +30,21 @@ const FORMAT_CAPABILITIES = {
30
30
  variant: "spreadsheet",
31
31
  hasLayoutPath: false
32
32
  },
33
+ csv: {
34
+ format: "csv",
35
+ variant: "spreadsheet",
36
+ hasLayoutPath: false
37
+ },
33
38
  odg: {
34
39
  format: "odg",
35
40
  variant: "drawing",
36
41
  hasLayoutPath: true
37
42
  },
43
+ svg: {
44
+ format: "svg",
45
+ variant: "drawing",
46
+ hasLayoutPath: true
47
+ },
38
48
  odf: {
39
49
  format: "odf",
40
50
  variant: "formula",
@@ -35,6 +35,10 @@ const markdownPdfCodec = zod.z.codec(require_model_bytes.MarkdownBytesSchema, re
35
35
  decode: (markdownBytes) => require_convert_convert.markdownToPdf(markdownBytes),
36
36
  encode: (pdfBytes) => require_convert_convert.pdfToMarkdown(pdfBytes)
37
37
  });
38
+ const svgPdfCodec = zod.z.codec(require_model_bytes.SvgBytesSchema, require_model_bytes.PdfBytesSchema, {
39
+ decode: (svgBytes) => require_convert_convert.svgToPdf(svgBytes),
40
+ encode: (pdfBytes) => require_convert_convert.pdfToSvg(pdfBytes)
41
+ });
38
42
  const odtDocxCodec = zod.z.codec(require_model_bytes.OdtBytesSchema, require_model_bytes.DocxBytesSchema, {
39
43
  decode: (odtBytes) => require_convert_convert.odtToDocx(odtBytes),
40
44
  encode: (docxBytes) => require_convert_convert.docxToOdt(docxBytes)
@@ -59,18 +63,44 @@ const xlsxMarkdownCodec = zod.z.codec(require_model_bytes.XlsxBytesSchema, requi
59
63
  decode: (xlsxBytes) => require_convert_convert.xlsxToMarkdown(xlsxBytes),
60
64
  encode: (markdownBytes) => require_convert_convert.markdownToXlsx(markdownBytes)
61
65
  });
66
+ const csvPdfCodec = zod.z.codec(require_model_bytes.CsvBytesSchema, require_model_bytes.PdfBytesSchema, {
67
+ decode: (csvBytes) => require_convert_convert.csvToPdf(csvBytes),
68
+ encode: (pdfBytes) => require_convert_convert.pdfToCsv(pdfBytes)
69
+ });
70
+ const odsCsvCodec = zod.z.codec(require_model_bytes.OdsBytesSchema, require_model_bytes.CsvBytesSchema, {
71
+ decode: (odsBytes) => require_convert_convert.odsToCsv(odsBytes),
72
+ encode: (csvBytes) => require_convert_convert.csvToOds(csvBytes)
73
+ });
74
+ const xlsxCsvCodec = zod.z.codec(require_model_bytes.XlsxBytesSchema, require_model_bytes.CsvBytesSchema, {
75
+ decode: (xlsxBytes) => require_convert_convert.xlsxToCsv(xlsxBytes),
76
+ encode: (csvBytes) => require_convert_convert.csvToXlsx(csvBytes)
77
+ });
78
+ const odgSvgCodec = zod.z.codec(require_model_bytes.OdgBytesSchema, require_model_bytes.SvgBytesSchema, {
79
+ decode: (odgBytes) => require_convert_convert.odgToSvg(odgBytes),
80
+ encode: (svgBytes) => require_convert_convert.svgToOdg(svgBytes)
81
+ });
82
+ const csvMarkdownCodec = zod.z.codec(require_model_bytes.CsvBytesSchema, require_model_bytes.MarkdownBytesSchema, {
83
+ decode: (csvBytes) => require_convert_convert.csvToMarkdown(csvBytes),
84
+ encode: (markdownBytes) => require_convert_convert.markdownToCsv(markdownBytes)
85
+ });
62
86
  //#endregion
87
+ exports.csvMarkdownCodec = csvMarkdownCodec;
88
+ exports.csvPdfCodec = csvPdfCodec;
63
89
  exports.docxPdfCodec = docxPdfCodec;
64
90
  exports.markdownDocxCodec = markdownDocxCodec;
65
91
  exports.markdownOdtCodec = markdownOdtCodec;
66
92
  exports.markdownPdfCodec = markdownPdfCodec;
67
93
  exports.odgPdfCodec = odgPdfCodec;
94
+ exports.odgSvgCodec = odgSvgCodec;
68
95
  exports.odpPdfCodec = odpPdfCodec;
69
96
  exports.odpPptxCodec = odpPptxCodec;
97
+ exports.odsCsvCodec = odsCsvCodec;
70
98
  exports.odsPdfCodec = odsPdfCodec;
71
99
  exports.odsXlsxCodec = odsXlsxCodec;
72
100
  exports.odtDocxCodec = odtDocxCodec;
73
101
  exports.odtPdfCodec = odtPdfCodec;
74
102
  exports.pptxPdfCodec = pptxPdfCodec;
103
+ exports.svgPdfCodec = svgPdfCodec;
104
+ exports.xlsxCsvCodec = xlsxCsvCodec;
75
105
  exports.xlsxMarkdownCodec = xlsxMarkdownCodec;
76
106
  exports.xlsxPdfCodec = xlsxPdfCodec;
@@ -8,11 +8,17 @@ declare const odsPdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8
8
8
  declare const odgPdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
9
9
  declare const xlsxPdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
10
10
  declare const markdownPdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
11
+ declare const svgPdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
11
12
  declare const odtDocxCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
12
13
  declare const odpPptxCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
13
14
  declare const odsXlsxCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
14
15
  declare const markdownDocxCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
15
16
  declare const markdownOdtCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
16
17
  declare const xlsxMarkdownCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
18
+ declare const csvPdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
19
+ declare const odsCsvCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
20
+ declare const xlsxCsvCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
21
+ declare const odgSvgCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
22
+ declare const csvMarkdownCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
17
23
  //#endregion
18
- export { docxPdfCodec, markdownDocxCodec, markdownOdtCodec, markdownPdfCodec, odgPdfCodec, odpPdfCodec, odpPptxCodec, odsPdfCodec, odsXlsxCodec, odtDocxCodec, odtPdfCodec, pptxPdfCodec, xlsxMarkdownCodec, xlsxPdfCodec };
24
+ export { csvMarkdownCodec, csvPdfCodec, docxPdfCodec, markdownDocxCodec, markdownOdtCodec, markdownPdfCodec, odgPdfCodec, odgSvgCodec, odpPdfCodec, odpPptxCodec, odsCsvCodec, odsPdfCodec, odsXlsxCodec, odtDocxCodec, odtPdfCodec, pptxPdfCodec, svgPdfCodec, xlsxCsvCodec, xlsxMarkdownCodec, xlsxPdfCodec };
@@ -8,11 +8,17 @@ declare const odsPdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8
8
8
  declare const odgPdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
9
9
  declare const xlsxPdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
10
10
  declare const markdownPdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
11
+ declare const svgPdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
11
12
  declare const odtDocxCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
12
13
  declare const odpPptxCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
13
14
  declare const odsXlsxCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
14
15
  declare const markdownDocxCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
15
16
  declare const markdownOdtCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
16
17
  declare const xlsxMarkdownCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
18
+ declare const csvPdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
19
+ declare const odsCsvCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
20
+ declare const xlsxCsvCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
21
+ declare const odgSvgCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
22
+ declare const csvMarkdownCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
17
23
  //#endregion
18
- export { docxPdfCodec, markdownDocxCodec, markdownOdtCodec, markdownPdfCodec, odgPdfCodec, odpPdfCodec, odpPptxCodec, odsPdfCodec, odsXlsxCodec, odtDocxCodec, odtPdfCodec, pptxPdfCodec, xlsxMarkdownCodec, xlsxPdfCodec };
24
+ export { csvMarkdownCodec, csvPdfCodec, docxPdfCodec, markdownDocxCodec, markdownOdtCodec, markdownPdfCodec, odgPdfCodec, odgSvgCodec, odpPdfCodec, odpPptxCodec, odsCsvCodec, odsPdfCodec, odsXlsxCodec, odtDocxCodec, odtPdfCodec, pptxPdfCodec, svgPdfCodec, xlsxCsvCodec, xlsxMarkdownCodec, xlsxPdfCodec };
@@ -1,5 +1,5 @@
1
- import { DocxBytesSchema, MarkdownBytesSchema, OdgBytesSchema, OdpBytesSchema, OdsBytesSchema, OdtBytesSchema, PdfBytesSchema, PptxBytesSchema, XlsxBytesSchema } from "../model/bytes.js";
2
- import { docxToMarkdown, docxToOdt, docxToPdf, markdownToDocx, markdownToOdt, markdownToPdf, markdownToXlsx, odgToPdf, odpToPdf, odpToPptx, odsToPdf, odsToXlsx, odtToDocx, odtToMarkdown, odtToPdf, pdfToDocx, pdfToMarkdown, pdfToOdg, pdfToOdp, pdfToOds, pdfToOdt, pdfToPptx, pdfToXlsx, pptxToOdp, pptxToPdf, xlsxToMarkdown, xlsxToOds, xlsxToPdf } from "./convert.js";
1
+ import { CsvBytesSchema, DocxBytesSchema, MarkdownBytesSchema, OdgBytesSchema, OdpBytesSchema, OdsBytesSchema, OdtBytesSchema, PdfBytesSchema, PptxBytesSchema, SvgBytesSchema, XlsxBytesSchema } from "../model/bytes.js";
2
+ import { csvToMarkdown, csvToOds, csvToPdf, csvToXlsx, docxToMarkdown, docxToOdt, docxToPdf, markdownToCsv, markdownToDocx, markdownToOdt, markdownToPdf, markdownToXlsx, odgToPdf, odgToSvg, odpToPdf, odpToPptx, odsToCsv, odsToPdf, odsToXlsx, odtToDocx, odtToMarkdown, odtToPdf, pdfToCsv, pdfToDocx, pdfToMarkdown, pdfToOdg, pdfToOdp, pdfToOds, pdfToOdt, pdfToPptx, pdfToSvg, pdfToXlsx, pptxToOdp, pptxToPdf, svgToOdg, svgToPdf, xlsxToCsv, xlsxToMarkdown, xlsxToOds, xlsxToPdf } from "./convert.js";
3
3
  import { z } from "zod";
4
4
  //#region src/convert/codec.ts
5
5
  const docxPdfCodec = z.codec(DocxBytesSchema, PdfBytesSchema, {
@@ -34,6 +34,10 @@ const markdownPdfCodec = z.codec(MarkdownBytesSchema, PdfBytesSchema, {
34
34
  decode: (markdownBytes) => markdownToPdf(markdownBytes),
35
35
  encode: (pdfBytes) => pdfToMarkdown(pdfBytes)
36
36
  });
37
+ const svgPdfCodec = z.codec(SvgBytesSchema, PdfBytesSchema, {
38
+ decode: (svgBytes) => svgToPdf(svgBytes),
39
+ encode: (pdfBytes) => pdfToSvg(pdfBytes)
40
+ });
37
41
  const odtDocxCodec = z.codec(OdtBytesSchema, DocxBytesSchema, {
38
42
  decode: (odtBytes) => odtToDocx(odtBytes),
39
43
  encode: (docxBytes) => docxToOdt(docxBytes)
@@ -58,5 +62,25 @@ const xlsxMarkdownCodec = z.codec(XlsxBytesSchema, MarkdownBytesSchema, {
58
62
  decode: (xlsxBytes) => xlsxToMarkdown(xlsxBytes),
59
63
  encode: (markdownBytes) => markdownToXlsx(markdownBytes)
60
64
  });
65
+ const csvPdfCodec = z.codec(CsvBytesSchema, PdfBytesSchema, {
66
+ decode: (csvBytes) => csvToPdf(csvBytes),
67
+ encode: (pdfBytes) => pdfToCsv(pdfBytes)
68
+ });
69
+ const odsCsvCodec = z.codec(OdsBytesSchema, CsvBytesSchema, {
70
+ decode: (odsBytes) => odsToCsv(odsBytes),
71
+ encode: (csvBytes) => csvToOds(csvBytes)
72
+ });
73
+ const xlsxCsvCodec = z.codec(XlsxBytesSchema, CsvBytesSchema, {
74
+ decode: (xlsxBytes) => xlsxToCsv(xlsxBytes),
75
+ encode: (csvBytes) => csvToXlsx(csvBytes)
76
+ });
77
+ const odgSvgCodec = z.codec(OdgBytesSchema, SvgBytesSchema, {
78
+ decode: (odgBytes) => odgToSvg(odgBytes),
79
+ encode: (svgBytes) => svgToOdg(svgBytes)
80
+ });
81
+ const csvMarkdownCodec = z.codec(CsvBytesSchema, MarkdownBytesSchema, {
82
+ decode: (csvBytes) => csvToMarkdown(csvBytes),
83
+ encode: (markdownBytes) => markdownToCsv(markdownBytes)
84
+ });
61
85
  //#endregion
62
- export { docxPdfCodec, markdownDocxCodec, markdownOdtCodec, markdownPdfCodec, odgPdfCodec, odpPdfCodec, odpPptxCodec, odsPdfCodec, odsXlsxCodec, odtDocxCodec, odtPdfCodec, pptxPdfCodec, xlsxMarkdownCodec, xlsxPdfCodec };
86
+ export { csvMarkdownCodec, csvPdfCodec, docxPdfCodec, markdownDocxCodec, markdownOdtCodec, markdownPdfCodec, odgPdfCodec, odgSvgCodec, odpPdfCodec, odpPptxCodec, odsCsvCodec, odsPdfCodec, odsXlsxCodec, odtDocxCodec, odtPdfCodec, pptxPdfCodec, svgPdfCodec, xlsxCsvCodec, xlsxMarkdownCodec, xlsxPdfCodec };
@@ -16,6 +16,12 @@ const require_odf_odp_read = require("../odf/odp/read.cjs");
16
16
  const require_odf_ods_read = require("../odf/ods/read.cjs");
17
17
  const require_odf_odg_read = require("../odf/odg/read.cjs");
18
18
  const require_markdown_text = require("../markdown/text.cjs");
19
+ const require_csv_text = require("../csv/text.cjs");
20
+ const require_csv_read = require("../csv/read.cjs");
21
+ const require_csv_write = require("../csv/write.cjs");
22
+ const require_svg_text = require("../svg/text.cjs");
23
+ const require_svg_read = require("../svg/read.cjs");
24
+ const require_svg_write = require("../svg/write.cjs");
19
25
  const require_layout_engine = require("../layout/engine.cjs");
20
26
  const require_layout_slides = require("../layout/slides.cjs");
21
27
  const require_ports_abort = require("../ports/abort.cjs");
@@ -39,8 +45,13 @@ const CONTENT_FORMATS = [
39
45
  "odp",
40
46
  "ods",
41
47
  "odg",
48
+ "svg",
49
+ "csv",
42
50
  "markdown"
43
51
  ];
52
+ function isTextFormatNode(node) {
53
+ return !node.hasSourcePackage;
54
+ }
44
55
  const FORMAT_NODES = {
45
56
  docx: {
46
57
  variant: "wordprocessing",
@@ -105,6 +116,18 @@ const FORMAT_NODES = {
105
116
  encode: (pkg) => (0, odf_js.encodePackage)(pkg),
106
117
  hasSourcePackage: true
107
118
  },
119
+ svg: {
120
+ variant: "drawing",
121
+ family: "svg",
122
+ decode: (bytes) => require_svg_text.decodeSvgText(bytes),
123
+ read: (text, options) => require_svg_read.readSvgContent(text, { onSvgDiagnostic: options?.onSvgDiagnostic }),
124
+ build: (content, options) => require_svg_write.buildSvgText(content, {
125
+ page: options?.page,
126
+ onSvgDiagnostic: options?.onSvgDiagnostic
127
+ }),
128
+ encode: (text) => require_svg_text.encodeSvgText(text),
129
+ hasSourcePackage: false
130
+ },
108
131
  markdown: {
109
132
  variant: "wordprocessing",
110
133
  family: "markdown",
@@ -116,6 +139,21 @@ const FORMAT_NODES = {
116
139
  build: (content) => require_markdown_write.buildMarkdownText(content),
117
140
  encode: (text) => require_markdown_text.encodeMarkdownText(text),
118
141
  hasSourcePackage: false
142
+ },
143
+ csv: {
144
+ variant: "spreadsheet",
145
+ family: "csv",
146
+ decode: (bytes) => require_csv_text.decodeCsvText(bytes),
147
+ read: (text, options) => require_csv_read.readCsvContent(text, {
148
+ delimiter: options?.delimiter,
149
+ onCellTypeInference: options?.onCellTypeInference
150
+ }),
151
+ build: (content, options) => require_csv_write.buildCsvText(content, {
152
+ delimiter: options?.delimiter,
153
+ sheet: options?.sheet
154
+ }),
155
+ encode: (text) => require_csv_text.encodeCsvText(text),
156
+ hasSourcePackage: false
119
157
  }
120
158
  };
121
159
  const LAYOUT_CAPABLE = /* @__PURE__ */ new Set([
@@ -125,6 +163,7 @@ const LAYOUT_CAPABLE = /* @__PURE__ */ new Set([
125
163
  "odp",
126
164
  "ods",
127
165
  "odg",
166
+ "svg",
128
167
  "markdown"
129
168
  ]);
130
169
  const TRANSFORMS = {
@@ -162,7 +201,7 @@ function executeBridge(source, target, bytes, options) {
162
201
  const sourceNode = FORMAT_NODES[source];
163
202
  const targetNode = FORMAT_NODES[target];
164
203
  let content;
165
- if (sourceNode.family === "markdown") {
204
+ if (isTextFormatNode(sourceNode)) {
166
205
  const text = sourceNode.decode(bytes);
167
206
  content = sourceNode.read(text, options);
168
207
  } else {
@@ -182,8 +221,8 @@ function executeBridge(source, target, bytes, options) {
182
221
  formatVersion: document_schema_js.DOCUMENT_PACKAGE_FORMAT_VERSION,
183
222
  content: buildContent
184
223
  });
185
- if (targetNode.family === "markdown") {
186
- const text = targetNode.build(buildContent);
224
+ if (isTextFormatNode(targetNode)) {
225
+ const text = targetNode.build(buildContent, options);
187
226
  return targetNode.encode(text);
188
227
  }
189
228
  const pkg = targetNode.build(buildContent, options);
@@ -194,7 +233,7 @@ function executeToPdf(format, bytes, options) {
194
233
  const node = FORMAT_NODES[format];
195
234
  let content;
196
235
  let fonts;
197
- if (node.family === "markdown") {
236
+ if (isTextFormatNode(node)) {
198
237
  require_ports_abort.throwIfAborted(options?.signal);
199
238
  const text = node.decode(bytes);
200
239
  const read = node.read(text, options);
@@ -295,7 +334,10 @@ function executeFromPdf(target, bytes, options) {
295
334
  signal: options?.signal,
296
335
  sink: options?.sink
297
336
  });
298
- const content = RECONSTRUCTORS[node.variant](layout, { signal: options?.signal });
337
+ const content = RECONSTRUCTORS[node.variant](layout, {
338
+ signal: options?.signal,
339
+ onCellTypeInference: options?.onCellTypeInference
340
+ });
299
341
  const pages = layout.pages.map((page) => ({
300
342
  widthPt: page.widthPt,
301
343
  heightPt: page.heightPt
@@ -305,8 +347,8 @@ function executeFromPdf(target, bytes, options) {
305
347
  content,
306
348
  pages
307
349
  });
308
- if (node.family === "markdown") {
309
- const text = node.build(content);
350
+ if (isTextFormatNode(node)) {
351
+ const text = node.build(content, options);
310
352
  return node.encode(text);
311
353
  }
312
354
  const pkg = node.build(content);