How can I render Typst documents on a website?

I have a complex document with many options. I want people to be able to pick which sections are included, the text size, and a few other bits and pieces. I have created the Typst document such that it reads configuration settings from a JSON file. And I have separately created a website with buttons which creates the JSON. I would like to embed the Typst WASM plugin and Typst file into the website, so people can generate the version of the document they want on demand.

Has anyone managed to do this?

I found a project on GitHub which claims to help, but all I can get out of it are javascript syntax errors.

Well, I’ve got this working now, using Typst.ts from Myriad-Dreamin instead, as recommended to me on Reddit. It’s viewable at The Drachenwald Book of Ceremonies.

Suggestions for improvement are welcome.

It does include a package (Hydra) which includes another (oxifmt). So both of those are downloaded from the packages server to render the PDF, which is perhaps less than ideal. I might try inlining them both, but I’m not sure it would actually be much of a speed win.

My next job is to add a font selector. That’ll be fun.

2 Likes

I think Myriad has a font pkg