A typst plugin for unit-aware calculations
typst
at main 42 lines 1.4 kB view raw view rendered
1# Evaltor: Typst plugin for unit-aware calculations 2 3I initially wanted to use [numbat](https://github.com/sharkdp/numbat) but since it requires access to filesystem (which is not allowed in typst), I ended up choosing [fend](https://printfn.github.io/fend) as the backend. 4 5If I find `fend` to be limiting, I will try to implement in-memory module importer in `numbat` where all the `nbt` files are imported at compile-time. 6 7Built using [typst-wasm](https://github.com/sjfhsjfh/typst-wasm). 8 9First compile the rust code to wasm32 using: 10 11```sh 12rustup target add wasm32-unknown-unknown 13cargo build --release --target wasm32-unknown-unknown 14``` 15 16Then install the typst package locally using [tlp](https://tangled.org/vidyasagarv.com/tlp) or [utpm](https://github.com/typst-community/utpm): 17 18```sh 19tlp init 20``` 21 22Then you can directly use in typst like: 23 24```typ 25#import "@local/evaltor:0.1.0": print_eval 26 27#print_eval("2 km + 30 m") 28``` 29 30will produce the output: 31 32``` 332 km + 30 m = 2.03 km 34``` 35 36For more details, see [examples.typ](tests/examples.typ) and [fend manual](https://printfn.github.io/fend/documentation/). 37 38 39## Plans 40- Add [rink](https://github.com/tiffany352/rink-rs/) as a backend, gives preference to unit over operation unlike fend. 41- Use [unify](https://github.com/ChHecker/unify) or [zero](https://github.com/Mc-Zen/zero) to format input and output. 42- Check out [numr](https://github.com/nasedkinpv/numr)