Skip to content

Support the csv and svg formats documents.js 2.3.0 declares - #220

Merged
Mearman merged 3 commits into
mainfrom
feat/csv-svg-formats
Aug 17, 2026
Merged

Support the csv and svg formats documents.js 2.3.0 declares#220
Mearman merged 3 commits into
mainfrom
feat/csv-svg-formats

Conversation

@Mearman

@Mearman Mearman commented Aug 17, 2026

Copy link
Copy Markdown
Member

documents.js 2.1.0 added csv and 2.2.0 added svg to the DocumentFormat union, which broke two of this CLI's exhaustive format enumerations (src/format.ts's Record<DocumentFormat, string> pair and the TUI's documentWithPath switch). This carries the documents.js 2.3.0 bump together with real handling for both formats, so the dependency moves with the code that knows about it rather than ahead of it.

What changed

csv and svg as first-class formats end to end (144c37b)

  • format.ts infers .csv/.svg from extensions in both directions, so the generic convert command and --to/output-path resolution accept them; the explicit csv-*/svg-*/*-csv/*-svg pairs of createLocalDocumentConverter()'s new full conversion matrix register as commands automatically, exactly like every existing pair.
  • The TUI opens .csv/.svg the way .xlsx already opens: a one-shot csvToPdf/svgToPdf at open time, browsed read-only through the shared pdf page-list screens, with the original bytes kept so a later export re-runs the conversion with the caller's own fonts and diagnostics. Save is rejected as read-only; undo and open-status routing cover the two new document shapes.

--delimiter, --sheet, and --page (c25ebea)

  • documents.js's ConversionOptions gained three csv/svg edge selections; without flags to answer them, a csv target over a multi-sheet source or an svg target over a multi-page source always failed with no remedy. --delimiter <char> reaches a csv read and write edge, --sheet <name> a csv write edge, --page <index> (0-based) an svg write edge.
  • Registered only on the explicit commands whose fixed pair can reach the edge, and unconditionally on convert/from-package whose target resolves at run time — the same registration reasoning the font flags already follow. from-package builds csv/svg targets through the codec's own buildCsvText/buildSvgText, since buildDocumentBytes's content.write contract is options-free.
  • CsvSheetNotSpecifiedError, CsvSheetNotFoundError, SvgMultiPageNotSpecifiedError, and SvgPageNotFoundError map to exit 3 (needs-info): documents.js already names the sheets or page count to pick from.

Docs (c2a5312) — the README's conversion enumeration stated the pre-csv/svg matrix as counts (nine/eight/sixteen); it now states the matrix structurally, plus the new flags, the csv/svg rejection behaviour of fonts/set-metadata, exit 3's new causes, and the TUI read-only previews.

Verification

pnpm lint, pnpm typecheck, pnpm build, pnpm test, pnpm test:smoke, and pnpm test:workers all pass locally. New coverage: unit tests driving the real commander program against a multi-sheet .ods and a multi-page .odg (exit 3 + remedy for each ambiguity, delimiter/sheet/page reaching the right edge, csv and svg through the generic convert), exit-code mapping tests for the four new error classes, and smoke tests spawning the built dist/cli.js for csv→pdf, --sheet, and --page end to end.

_Generated by Claude Code

documents.js 2.1.0 added csv and 2.2.0 added svg to the DocumentFormat
union, which broke this CLI's two exhaustive format enumerations
(src/format.ts's Record<DocumentFormat, string> pairs and the TUI's
documentWithPath switch). Both formats are now full members everywhere
a format is named:

- format.ts infers .csv/.svg from extensions both directions, so the
  generic convert command and --to/--out resolution accept them, and
  the explicit csv/svg pairs of createLocalDocumentConverter()'s new
  full matrix register as commands automatically.
- The TUI opens .csv/.svg the same way .xlsx already opens: one-shot
  csvToPdf/svgToPdf at open time, browsed read-only through the shared
  pdf page-list screens, with the original bytes kept so export re-runs
  the conversion with caller fonts. Save is rejected as read-only, and
  undo/open-status routing covers the two new document shapes.
documents.js's ConversionOptions gained three csv/svg edge selections;
without flags to answer them, a csv target over a multi-sheet source or
an svg target over a multi-page source always fails with no remedy.

- --delimiter <char> reaches a csv source's read edge and a csv
  target's write edge; --sheet <name> a csv target's write edge;
  --page <index> an svg target's write edge (0-based, matching the
  index SvgPageNotFoundError itself reports).
- Registered only on the explicit commands whose fixed pair can reach
  the edge, and unconditionally on convert and from-package, whose
  target resolves only at run time -- the same reasoning the font
  flags already document.
- from-package builds csv/svg targets through the codec's own
  buildCsvText/buildSvgText (buildDocumentBytes's content.write
  contract is options-free, so a selection would have no path through
  it).
- CsvSheetNotSpecifiedError, CsvSheetNotFoundError,
  SvgMultiPageNotSpecifiedError, and SvgPageNotFoundError map to
  EXIT_NEEDS_INFO (3): documents.js already names the sheets or page
  count to pick from, so the fix is supplying more information, not a
  different file.
The README's conversion enumeration still described the pre-csv/svg
matrix (nine <format>-to-pdf commands, eight pdf-to-<format>, sixteen
bridges); the converter now declares a full matrix with csv and svg as
first-class members, so the Commands section states the matrix
structurally (every ordered pair of the ten content formats, each plus
odf into pdf, pdf back into the same ten) rather than enumerating a
count that will rot again. Also covers: the three selection flags in
Shared flags, the csv/svg clauses of fonts/metadata/set-metadata
rejection behaviour, exit 3's new csv-sheet/svg-page causes, the TUI's
csv/svg read-only PDF previews, and the package/program description
strings naming the two new formats.
@Mearman
Mearman merged commit 72a98a3 into main Aug 17, 2026
9 checks passed
@Mearman
Mearman deleted the feat/csv-svg-formats branch August 17, 2026 20:42
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 2.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant