A port of the Typst typesetting engine to MoonBit.
Dependencies
| Path | Contents |
|---|---|
| syntax/ | Port of typst-syntax: lexer, parser, syntax nodes, spans, Lines, paths and file ids (path.rs), packages and manifests (package.rs) |
| syntax/ast/ | Typed AST over the syntax tree (ast.rs) |
| unicode/ | Unicode property tables generated from the Rust crates upstream uses |
| codecs/ | Image codecs upstream gets from crates: PNG decode/encode (png, fdeflate), JPEG/GIF/WebP headers (zune-jpeg, gif, image-webp), EXIF (kamadak-exif), inflate |
| svg/ | Port of typst-svg (so far: WebImage data URLs) |
| oracle/ | Rust crate dumping upstream reference outputs (goldens) |
| tests/runner/ | Differential runner comparing the port against the goldens |
| kit/, kit/platform/ | Port of typst-kit (files, packages, fonts, diagnostics) and OS access for native and wasm |
| cli/ | Port of typst-cli: the typst command line |
| typst_assets/fonts/ | The fonts embedded into the CLI (generated) |
| scripts/ | upstream.sh (pinned checkout), goldens.sh (regenerate goldens) |
moon run cli --target native --release -- compile input.typ output.pdf
moon run cli --target wasm-gc -- compile input.typ 'page-{p}.svg'
moon run cli --target native -- compile --format html --features html in.typ
moon run cli --target native -- eval 'query(heading).len()' --in input.typ
moon run cli --target native -- fonts --variantsfn report() -> @doc.Document {
@doc.Document([
@doc.SetPage(paper="a5", margin=@doc.Sides(all=@doc.Cm(1.8))),
@doc.SetHeading(numbering=@doc.Numbering("1.")),
@doc.Heading("Build times"),
(
$|Running text is a multiline string; inline elements such as
$|\{@doc.Emph("emphasis")} and \{@doc.Raw("code")} are interpolated.
)
|> @doc.Prose,
@doc.Equation("sum_(k=1)^n k = (n(n+1))/2", block=true),
])
}
fn run() -> Unit raise {
let world = @system.world(root=".", system_fonts=false, today=(2026, 10, 5))
let compiled = report().compile_paged(world)
@system.write("report.pdf", compiled.pdf().unwrap())
}scripts/upstream.sh # checkout upstream at UPSTREAM_REV
scripts/goldens.sh # needs Rust; or `scripts/goldens.sh syntax ast`
moon run tests/runner --target native -- syntax [filter] [-v]
moon run tests/runner --target native -- ast [filter] [-v]Install
Download zipA port of the Typst typesetting engine to MoonBit.
Dependencies