Support the csv and svg formats documents.js 2.3.0 declares - #220
Merged
Conversation
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.
This was referenced Aug 17, 2026
Contributor
|
🎉 This PR is included in version 2.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
documents.js 2.1.0 added
csvand 2.2.0 addedsvgto theDocumentFormatunion, which broke two of this CLI's exhaustive format enumerations (src/format.ts'sRecord<DocumentFormat, string>pair and the TUI'sdocumentWithPathswitch). 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.tsinfers.csv/.svgfrom extensions in both directions, so the genericconvertcommand and--to/output-path resolution accept them; the explicitcsv-*/svg-*/*-csv/*-svgpairs ofcreateLocalDocumentConverter()'s new full conversion matrix register as commands automatically, exactly like every existing pair..csv/.svgthe way.xlsxalready opens: a one-shotcsvToPdf/svgToPdfat 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)ConversionOptionsgained 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.convert/from-packagewhose target resolves at run time — the same registration reasoning the font flags already follow.from-packagebuilds csv/svg targets through the codec's ownbuildCsvText/buildSvgText, sincebuildDocumentBytes'scontent.writecontract is options-free.CsvSheetNotSpecifiedError,CsvSheetNotFoundError,SvgMultiPageNotSpecifiedError, andSvgPageNotFoundErrormap to exit3(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, andpnpm test:workersall pass locally. New coverage: unit tests driving the real commander program against a multi-sheet.odsand a multi-page.odg(exit 3 + remedy for each ambiguity, delimiter/sheet/page reaching the right edge, csv and svg through the genericconvert), exit-code mapping tests for the four new error classes, and smoke tests spawning the builtdist/cli.jsfor csv→pdf,--sheet, and--pageend to end._Generated by Claude Code