Skip to content

API/well-defined capacity for writing new exporters (inc. third party ones) #3304

Open

Description

@Hugo-Heagren

Description

I want to be able to write my own exporters for typst in arbitrary formats, as plugins or extensions to the compiler, and to download and use those which others have written. Pandoc and org-mode have similar features.

To be clear, I am not requesting any specific new exporters be added (html/latex/epub etc.). I recognise that adding built-in support for a plethora of different formats is well beyond what typst is supposed to do. Rather, I'd like it if I (or others) could do the support-per-format part, on top of well-documented api for building such exporters. I imagine that this would take the form of a rust lib, and some documentation on the site about how to build such exporters. Ideally the exporters typst does ship with (pdf and hopefully soon HTML) would be implemented in exactly the same way, and thus serve as good examplars.

Use Case

At the moment I do all my writing in org mode, and I really its multiple, customisable, export functionality. If I write a long message for the charity I volunteer for, I can write it once, export to whatsapp markdown and paste that into whatsapp, then export again to pdf, html and ascii, and paste/attach them to an email. Different people need different things, and I write once, post multiple times. Similar but different: in my PhD I often need to produce LaTeX sources for things I've written, especially for journals, or layout my work with LaTeX-specific tooling (e.g. 'please use our custom class file').

The whatsapp use-case is a really good example. When I found that I might need to do this, I wrote a whatsapp exporter and used that. It probably took about about an hour and after that I made it publicly available.

I really like the exportability of org mode, but I don't like the syntax or the lack of portability (or the fact that it isn't at all well-specified or documented). Typst looks like a really great alternative, and this is the one thing holding me back from moving to it.

Activity

  1. added
    feature request
    on Jan 30, 2024
  2. added
    crate
    on Feb 4, 2024
  3. smheidrich commented on Aug 3, 2025

    @smheidrich

    For anyone looking for a workaround in the meantime:

    Pandoc does support Typst as input since version 3.1.3, so you can get something similar by letting it convert your Typst document to Pandoc's own json (= Pandoc AST) format via pandoc -t json your-document.typ and do your own transformations on that.

    But naturally this is and will likely always be lower-fidelity than exporters that have access to the internals of Typst itself, plus Pandoc will likely always lag behind Typst proper in terms of supported features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    cratefeature request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions