@deckyard/docs
Read, edit and write word-processing documents: Office Open XML (.docx, as Microsoft™ Word™ writes it), OpenDocument text (.odt, as LibreOffice™ writes it) and RTF, all through one value-semantic Document. Markdown, reStructuredText and MyST become documents through the bundled doctree, a document renders to HTML or PDF the same way, and a template made in an office suite is filled in without losing what the model cannot hold.
It is pure computation over bytes and never runs an office suite. Install with jvc add @deckyard/docs; it needs Jennifer 0.29.0 or newer and no capability beyond fs for open and save.
What it covers
| Subject | Guide |
|---|---|
| The document model: blocks, inlines, lists, tables, pictures, notes | The model |
| Markdown and doctree in, HTML and PDF out | Doctree and Markdown |
{{name}} placeholders in a DOCX or ODT | Templates |
| DOCX | DOCX |
| ODT | ODT |
| RTF | RTF |
Conventions
Snippets assume this import:
import "@deckyard/docs/" as docs;
def d as docs.Document init docs.fromMarkdown("# Notes\n\n- one\n- two\n");
docs.save($d, "notes.docx");The trailing slash resolves to the entry module. Every name is exported from it, so docs. reaches all of them.
Errors
| Kind | Raised for |
|---|---|
"docs" | A malformed file, a format this deck does not read, a document a format cannot hold (a list, note or picture that does not exist, a character XML forbids), a bad argument |
"limit" | A reached cap: MAX_NESTING, MAX_BLOCKS, MAX_SPAN, MAX_CELLS, MAX_INLINES, MAX_TEXT, MAX_INFLATED, MAX_ENTRIES; an XML part nested past 400 levels or holding more than about 2 million nodes; an RTF file past 4 Mi tokens or 256 MiB |
The generic kinds a library raises ("limit", "timeout", "closed", "net", "cancelled") pass through unchanged; any other fault while reading is rewrapped as "docs". File-system errors from open and save come from fs as they are.
Trademarks
Microsoft™ and Word™ are trademarks of Microsoft Corporation. LibreOffice™ is a trademark of The Document Foundation. Other product and company names may be trademarks of their respective owners. They are used only to identify the products this deck works with. This deck is an independent project, not affiliated with, sponsored or endorsed by Microsoft Corporation or The Document Foundation.