- HTML 56.9%
- Typst 42.6%
- Python 0.3%
- CSS 0.2%
| docs | update docs | |
| examples |
use maybe-html automatically in to-mathml and try-to-mathml
|
|
| src | fix mathfont include if the font is specified directly | |
| tests |
convert refs
|
|
| .gitignore | initial commit | |
| install.py | add install.py | |
| LICENSE | add LICENSE | |
| README.md | minor doc change | |
| typst.toml | add typst.toml | |
mathyml
mathyml converts your equations to MathML so that they work well with HTML export. See the manual for documentation.
Overview
Mathyml converts your typst equations to MathML Core. MathML Core is a language for describing mathematical notation and supported by major browsers (firefox and chrome). You can find an overview of MathML on mdn and in the specification.
Note that MathML rendering is certainly not perfect, some features work better and some worse. In general the output tends to look much better in firefox than chrome. See the section about missing/ non-working features below.
MathML Core is not complete and can't render everything itself. Instead it relies on Web Platform features (such as CSS) (see the explainer). You can find a list of of elements/ features used that do not come from MathML Core below.
Installation
Execute python install.py. This will install the mathyml package to the local package folder.
Quickstart
First, import mathyml and include the prelude, which defines replacements for elements which mathyml can't handle (e.g. bold or cal).
#import"@local/mathyml:0.1.0"#importmathyml:to-mathml#importmathyml.prelude:*Include the required stylesheet (and the mathfont):
#mathyml.stylesheets()Note that the mathfont is required, else the rendering looks really bad. The font is currently downloaded from github. I would recommend changing the font family to your liking and downloading the css files yourself (so that it works without an internet connection).
Convert equations manually:
Thefraction#to-mathml($1/3$)isnotadecimalnumber.Andweknow#to-mathml($a^2+b^2=c^2.$)You can also convert equations automatically.
If this panics, try try-to-mathml instead, which will create a svg on error.
#showmath.equation:to-mathmlTosolvethecubicequation$t^3+pt+q=0$(wheretherealnumbers$p,q$satisfy$4p^3+27q^2>0$)onecanuseCardano'sformula:$root(3,-q/2+sqrt(q^2/4+p^3/27))+root(3,-q/2-sqrt(q^2/4+p^3/27)).$Missing/ non-working features
You can find a list of all missing/ non-working features in the manual. Here you can see the html output for the examples and tests.