From 4551f9c554c1fef32ef2b7e55b01b1fb90186cbf Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Wed, 29 Apr 2026 15:10:29 +0200 Subject: feat(typst): minimal rust lib building svg --- typst/src/lib.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 typst/src/lib.rs (limited to 'typst/src/lib.rs') diff --git a/typst/src/lib.rs b/typst/src/lib.rs new file mode 100644 index 0000000..5d9dcc4 --- /dev/null +++ b/typst/src/lib.rs @@ -0,0 +1,24 @@ +//! Based on https://github.com/zeon256/minimal-typst-svg-renderer + +use typst::layout::PagedDocument; +use typst_svg::svg_frame; + +use crate::world::MinimalWorld; + +mod world; + +pub fn compile() { + let content = include_str!("../../template.typ"); + let world = MinimalWorld::new(content); + + let res = typst::compile::(&world); + + if !res.warnings.is_empty() { + eprintln!("Warnings: {:?}", res.warnings); + } + + let doc = res.output.expect("Error compiling typst"); + + let svg = svg_frame(&doc.pages[0].frame); + println!("{}", svg) +} -- cgit v1.2.3