How do I generate a Typst document from another document AST?

I’d go with “Pass the AST to Typst and build the document with Typst scripts”. It’s a bit low-level in this particular instance, but it’s basically what Typst scripting is made for. If you generate the source code instead, you do the same kind of scripting, just with worse ergonomics because you have to deal with strings of markup instead of content.

This thread is closely related:

If you prepare your AST as JSON (for example), e.g. using Serde, the rest should be fairly easy.

1 Like