diff options
| author | Anhgelus Morhtuuzh <william@herges.fr> | 2026-04-29 15:10:29 +0200 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <william@herges.fr> | 2026-04-29 15:10:29 +0200 |
| commit | 4551f9c554c1fef32ef2b7e55b01b1fb90186cbf (patch) | |
| tree | 0a1fc54632067dfff4c9beca8a3ce00056c45da9 /typst/src/lib.rs | |
| parent | 2f2014fb9cf9b22593088f0fcc16b8b9d8a436ae (diff) | |
feat(typst): minimal rust lib building svg
Diffstat (limited to 'typst/src/lib.rs')
| -rw-r--r-- | typst/src/lib.rs | 24 |
1 files changed, 24 insertions, 0 deletions
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::<PagedDocument>(&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) +} |
