aboutsummaryrefslogtreecommitdiff
path: root/typst/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'typst/src/lib.rs')
-rw-r--r--typst/src/lib.rs24
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)
+}