51 pointsby todsacerdoti3 days ago2 comments
  • progbits3 days ago
    I'm also building a blog with Typst, but I don't use the html export or the typst binary at all.

    Instead I only use it as a markup language and use the typst libraries to evaluate it into blocks/AST which I then use together with askama templates.

    This gives me a lot more flexibility, and typst is nicely extensible with custom typesafe functions. The downside is that existing LSP integrations don't recognize my custom keywords and show errors, something I just accept for now but might work around by importing a lib.ty stub (without real implementation, just matching signatures).

    • Rochus3 days ago
      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?
      • progbits2 days ago
        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.

        • Rochus2 days ago
          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?).
  • shakna3 days ago
    The HTML target being unstable, meaning I can't really build a half-decent ePub target from it, is probably the key blocker for me strongly considering Typst for my workflow.

    For now, it's an unhappy marriage of pandoc, LaTeX, and a 20k LOC Lua ecosystem for me.