Skip to content

Templates for domain-specific rendering

Choose a tag to compare

@istathar istathar released this 23 Mar 23:30
· 392 commits to main since this release
v0.5.3
a98d69c

This release lands the ability to render Technqiue documents as PDFs.

Domains for specific use cases

A document written in Technique can have a "domain" which is the specific use-case for the procedure written in that document. This can be a simple checklist with simple structure and checkboxes or a more elaborate operations procedure, the original use case which inspired the language in the first place. We also include a recipe domain and template for cooking instructions, and finally we include nasa-esa-iss showing that Technique can be used to write the crew procedures used by astronauts aboard the International Space Station.

Two stage render pipeline

There are two stages to rendering a document: first is an "adapter" which takes the Technique language parser's internal Abstract Syntax Tree and de-normalizes it into a domain-specific object model suitable to the use case. This cleans up the complexity inherent in the internal representation and presents it as Rust types (with owned Strings, for example) that are laid out in a sensible manner for someone working in that domain.

The second stage is the "template". This has two parts. A tree-walk is done in Rust to iterate over the domain-specific data structures, converting to a series of Typst function invocations. The domain content, now in Typst form, is written to a temporary .typ file.

Then a default implementation for each function gives the Typst markup output for that object.

The domain can be specified with the --domain option:

$ technique render --domain=procedure examples/prototype/DatabaseProduction.tq

will render examples/prototype/DatabaseProduction.pdf as a procedure. If the user needs to override the builtin template they can do so by supplying their own Typst file via the --template option:

$ technique render --domain=procedure --template=my-company-procedure.typ examples/prototype/DatabaseProduction.tq

Finally a --keep option is available to keep the intermediate files in place, so that a user working on a template can then iterate using Typst directly. The intermediate files which are written to the same directory as the source document:

$ typst watch --root=. examples/prototype/.DatabaseProductiontyp examples/prototype/DatabaseProduction.pdf

Other Improvements

Full Changelog: v0.4.6...v0.5.3