Is it possible to render typst formula in html? #14572
DescriptionI am using katex as the rendering engine for formula in my quarto website project, and want to change to typst for better source code readability. However, as what I have read in the documents, it seems to be only possible to use typst when the output file is .typ/.pdf . Is there a way to integrate typst rendering engine into a website project, something like html-math-method:
method: typst? |
Replies: 3 comments 10 replies
|
No there isn't a native approach that will get you to have similar output as actual HTML JavaScript plugins such as MathJax and KaTeX. This being said, there is a Quarto extension to render any Typst content to any formats as images: |
|
@Guest-1013 I am curious of your suggestion. How do you envision being able to use typst for equation ? You would like to write typst syntax (https://typst.app/docs/reference/math/) because KaTeX syntax is not enough ? I don't know the full difference. If your output in HTML then you need in all case a render to HTML. KaTeX and Mathjax are such tool. Maybe something could become possible considering Typst experimental HTML export (https://typst.app/docs/reference/html/) but they do not yet handle Math element (typst/typst#5512) So using a tool like quarto-typst-render above seems to be the best solution today. It uses images like some other html math method like webtex. Also for context, all html math method in quarto as of today are inherited from pandoc supports: https://pandoc.org/MANUAL.html#math-rendering-in-html Thanks. |
|
Typst Render extension v0.21.0 is now able to use Typst 0.15 (Quarto 1.10) to produce HTML for regular text and equations. quarto render ...Caution Do not use in production yet:
---
format:
html: default
typst: default
engine: markdown
filters:
- typst-render
extensions:
typst-render:
math: typst
---
```{typst}
//| echo: fenced
//| format: html
#set text(size: 14pt)
A *Typst* paragraph with maths $f(x) = sum_(i=0)^n x_i$ rendered as MathML.
```
Inline $f(x) = sum_(i=0)^n x_i$ sits in the text, and a numbered display equation follows:
$$
e^(i pi) + 1 = 0
$$ {#eq-euler}
See @eq-euler for Euler's identity. |
No there isn't a native approach that will get you to have similar output as actual HTML JavaScript plugins such as MathJax and KaTeX.
This being said, there is a Quarto extension to render any Typst content to any formats as images: