AshTypst
Precompiled Rust NIFs for rendering Typst templates via an extensible data-encoding protocol with built-in Ash support. Compile markup to SVG, PDF, or HTML with persistent contexts that keep fonts and compiled state in memory for fast, iterative rendering.
Features
- Persistent context — font scans are cached process-wide and reused across contexts and compiles; call
AshTypst.refresh_fonts/0to pick up newly installed fonts - Multi-page rendering — compile once, render any page as SVG
- PDF export — proper binary output with page ranges, PDF/A standards, and document IDs
- HTML export — via
typst-html - Virtual files — inject data as in-memory
.typfiles your templates can#import - Sandboxed filesystem access — opt in to reading templates and assets from a root directory; disabled by default
- Streaming — feed large datasets from Elixir streams into virtual files in constant memory
sys.inputs— pass simple string parameters accessible via#sys.inputsin templates- Rich diagnostics — compile errors include line/column numbers
- Data encoding — the
AshTypst.Codeprotocol converts Elixir types (maps, lists, dates, decimals, Ash resources) to Typst syntax - Timezone-aware encoding — dates and times are automatically shifted to a configured timezone when encoding to Typst
- Ash Resource Extension - define template-rendering actions inside your resources via DSL
Documentation
- Get Started — installation, quick start, and a tour of the API
- Templating — structuring templates and injecting data the AshTypst way
- Multi-Language Documents — Gettext, translated content, CLDR formatting, CJK fonts
- Sensitive Data — what reaches templates and how to keep secrets out
- AshTypst.Resource DSL reference