typstgen
Compile an existing .typ file to PDF. No external typst binary, no
subprocess — Typst runs embedded as a Rust library. Template resolution is
config-driven instead of hardcoded.
your-document.typ + typstgen.toml (template_paths) → your-document.pdf
Usable three ways from one crate:
- CLI (
clifeature, default):typstgen compile input.typ - Rust library (always available):
typstgen::compile(path, &config) - Wasm (
wasmfeature): source and imports supplied as a JSON virtual filesystem
Why
docgen already does
PDF generation from Typst, but grew into a client/project-management tool
along the way and only ever hardcoded its template lookup paths. typstgen is
the minimal version of the same idea: one job (.typ in, PDF out), with the
template directory resolved from config instead of baked in.
See docs/PLAN.md for the full rationale, lessons carried over
from docgen, and the architecture reused from
renderreport (embedded Typst,
feature-gated CLI/Wasm, embedded-fonts-only on Wasm).
Quick start
# typstgen.toml
# Each path is a virtual filesystem root for absolute imports. They are
# searched in order; the first existing path is used.
= [".", "./templates"]
use ;
let config = load?;
let pdf_bytes = compile?;
write?;
Wasm
Build with cargo build --target wasm32-unknown-unknown --no-default-features --features wasm.
Pass source and importable text files as JSON; the returned bytes are a PDF:
License
MIT