#svg #typst #rsx #element #convert #document #ui

typst-2-rsx

Convert Typst documents into RSX SVG elements for use in Rust UI development

3 unstable releases

new 0.2.0 Feb 9, 2025
0.1.1 Feb 6, 2025
0.1.0 Feb 6, 2025

#280 in Images

Download history 227/week @ 2025-02-02

227 downloads per month

MIT/Apache

160KB
369 lines

typst-2-rsx

Convert Typst documents (.typ) into RSX elements as SVG components.

📌 Overview

typst-2-rsx is a Rust library that automates the conversion of Typst documents into RSX elements. It first uses the typst CLI to compile .typ files into .svg, and then parses the .svg file into RSX elements, making it easy to integrate Typst-generated content into Rust-based UI frameworks like Dioxus.

🚀 Installation

Using Cargo

cargo add typst-2-rsx

Or manually add to Cargo.toml:

[dependencies]
typst-2-rsx = "0.2.0"

Then run the cargo build to compile.

📖 Usage

use typst_2_rsx::typst_to_rsx;

let rsx_svg = typst_to_rsx("example.typ").expect("Conversion failed");
println!("{}", rsx_svg);

🔧 How It Works

  1. Compiles .typ to .svg using the typst CLI.
  2. Parses the generated .svg file.
  3. Transforms the SVG elements into RSX components.

🛠 Dependencies

  • typst-cli – Required for Typst compilation.
  • dioxus(optional) – For rendering RSX.

📜 License

This project is licensed under MIT OR Apache-2.0.

Dependencies

~3–9MB
~82K SLoC