back

by Rochus·9mo ago·view on hn ↗
Cool idea. So you essentially only use the Typst parser (i.e. the generated AST, I assume the text format of it)? With askama templates you essentially implement your own Typst renderer, which sounds like quite an achievement. May I assume that only a subset of Typst is supported by your renderer? What is the advantage of all this effort compared to e.g. Markdown or Asciidoc?
1 comments
Not just parser but the evaluator API (so imports, macros etc all work). You get back the AST as typed structs including own custom element types.

This is actually very little work to set up, have a look at: https://github.com/Relacibo/typst-as-lib (not my code, just something I found helpful)

It's a different set, not subset. I don't support some math and layout things that don't make sense on a webblog (or which I don't need). But I have custom elements for margin notes and such which typst doesn't have out of the box.

I don't like markdown - it's underspecified, typos turn into broken docs instead of compilation error and extending it is hard. I looked at rST which is close to what I want and what I would have used if I didn't find Typst, I just prefer the latter's syntax and also it's a rust library I can more easily work with.

Edit: also I'm not saying this is better or anything, it's just fun for me to build.

Sounds interesting. Have you published your generator somewhere? I don't understand yet what you exactly do with the askama templates (the result is Rust code, isn't it?).