Recipes

Start a document. create_doc {title, page: {w: 210, h: 297, unit: "mm"}, langs: ["en"]} gives a starter page, two open fonts (Jost, Bodoni Moda) and a small token set. Replace any of it.

Design system first. Put colours, text styles, the margin and the grid in tokens.edn; put shared pieces (folio, header, captions, a figure with caption) in lib/ as functions or doc/elements; keep pages short and declarative. Changing a token re-styles every page.

Re-format a document (deck to A4, A4 to letter): fork it (or branch), set doc.edn :page, rescale tokens.edn (type sizes are in document units), then rework lib/ and each page, rendering as you go. Copy and assets stay shared in meaning, so both versions say the same thing. What carries over badly, and needs a look on every page:

Several agents on one document. Give each agent its own pages (its own pages/*.clj files and their overrides) and keep lib/, tokens.edn and doc.edn with one owner; edits to different files never conflict. Every save is a version, so dozens of versions per agent are normal; snapshot when done.

Look, don't guess. render_page after every layout change, in each language (it also lists the copy keys and assets the page used, to compare against the page it replaces). Long words, longer translations and missing images show up there first. check at the end.

Replace an image without breaking the layout. upload_asset {asset: "img/x"} points the id at the new raw; frames, focus and framing stay.

Hand over. snapshot the version, build_pdf for each language/edition, and give the document link.