Claim: This is neither official supported nor exact the HTML export. I just find it cool so I'm going to share it.
Context: The format of documentation comments was discussed and we confirm that it should support typst syntax. However, LSP clients only supports docs in markdown format, but rarely support html format. Therefore, a "Markdown Export" is needed here. And since we know that it will be quite easy to get somewhat a "HTML Export" by exporting converted markdown then.
Since we suppose that the converting documents are all typst documentation, conforming some restricted syntaxes, it seems that they are usually not heavily styled or styles are separated from content. Even if there are some mixed styles, we should be able to drop them safely (looks sensible). By this assumption, a typst-to-markdown converter can be quite simple.
Besides converting documentation, I find it could be abused for publishing your (simple) documents to those platforms only accepting markdowns. For example, converting your README.typ to README.md. This could also be lossy, since people can continue reading styled PDF output of the documents if they would like to.
As a showcase, I run the tool on some GPT-generated typst document.
Source code: https://github.com/Myriad-Dreamin/tinymist/tree/main/crates/typlite
Ideas:
- convert the document as is at syntax-level.
- rendering some content if we have chances, like math equations or contextual expressions.
- drop styles and rest content of complex scripting.
Why not pandoc:
- I don't want to embed a pandoc in LSP or let LSP binary depend on some external pandoc binary, so I write a pure rust one.
- I want to customize the renderer a bit to fit in typst documentation perfectly.
Note: The current goal is only for converting documentation comments or some deadly simple documents. if someone is interested, they can send PRs to improve it.