hex.pm hex.pm Documentation hex.pm github.com

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/0 to 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 .typ files 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.inputs in templates
  • Rich diagnostics — compile errors include line/column numbers
  • Data encoding — the AshTypst.Code protocol 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