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:
:layout/overridesin the copy files hold the old layout's numbers in the old units; they are merged in as they are. Re-tune them for the new layout or remove them (only the overrides, never the words).- Forced line breaks (
\n) written into running text for the old measure break badly at a new width. Keep them in headlines; for running text, strip them in the page code or take them out of the copy. - Shared
lib/helpers written for the old size (full-bleed pages, grids) still compute in the old units: write a new helper rather than calling the old one. - A page too dense for the new format can become two:
add_pagewith an id likep12bat the index after it. Page numbers follow the order indoc.edn, so later folios renumber themselves.
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.