Typst for developers
Typst is a CLI tool that allows you to convert markup code (*.typ) into PDF pages. Or SVG or PNG if you prefere.
In many ways it is an alternative to LaTeX and is well suited to write complex documents in a simple fashion. As the examples on typst-website show it’s a great candidate for papers, invoices and even books.
For some of my client projects I regularly face the need to implement reports. For that I use tools like jsPDF and custom layout code to get the pages out in correct form. This works really well for simple designes and especially if the page flow is static. With static page flow I mean PDF designs that are fixed in their number of pages and only change some boxes or text parts depending on user input.
The story, however, becomes way more complicated when the application users are able to produce rich texts for reports or have forms that allow them to span tables accross multiple pages. In the past I used my custom table layout system for that and it worked a lot but every now and then I had to make compromises or just diverge from the client’s reference material.
With Typst I found an interesting alternative approach for this kind of job. It allows me to generat markups quickly in a nearly pixel perfect way and that even with the complexity of user controlled flow content.
What I like about Typst
- CLI: Makes it very flexible. In a Docker it’s easy to build an API that transforms user content + markup template into high quality report documents
- *.typ-syntax: It’s easy at the start and very powerful at the end
- code in markup: This means that you can write functions, yes functions(!), within the markup. And not just functions, but also loops, variables, data-maps, data-lists and more.
- WASM support using Myriad-Deamin’s WASM built. It just takes a few minutes to get it running in the browser. When combined with SVG output you can quickly build web components that shows report previews without the need for clunky PDF plugins or downloads. This can improve UX drastiaclly.
- GIT support As the markups are just text they can be managed with well known tools like git or be placed in database columns without much headache
That’s it. Cheers.
๐โโ๏ธ I’m human and can make mistakes. Please double-check my posts.