logoalt Hacker News

skwee357last Tuesday at 10:21 AM1 replyview on HN

The syntax feels complicated. Maybe I just don't have enough patience for learning a typesetting syntax (I never worked with Latex before).

On top of that, there is no easy way to create a template. For example, I want an invoice template which I can reuse with different data. Theoretically, I can create a typ file for the template, and define the invoice as a function which I then call from a string with, say, json data. It seems great as web service, but not as a library I can use from, say, Rust.

And the type system is a bit confusing. I can define basic types like numbers or string, but when it comes to structs, they don't seem to have support for that.

I find it easier to create a handlebars template, and feed the HTML to headless chrome printing service, which will output a PDF for me. It's not scalable for high volume, but good enough for my needs (takes about 2-3 seconds to generate PDF).


Replies

lugaolast Tuesday at 11:51 AM

> On top of that, there is no easy way to create a template

Templates are just functions [0].

I think much of the frustration comes from typesetting being a harder problem than it seems at first. In general a typesetting system tries to abstract away how layout is recomputed depending on content.

Supporting contextual content -- cases where the content depend on other content, e.g. numbered lists, numbered figures, references, etc -- involves iterative rendering. This is evidentidly a complexity sinkhole and having a turing complete script language will bite you back when dealing with it. I recommend reding their documentation about it [1] where they explain how they propose solving this problem.

[0]: https://typst.app/docs/tutorial/making-a-template/

[1]: https://typst.app/docs/reference/context/#compiler-iteration...