package mathjax
Import Path
github.com/d2lang/mathjax-go (on go.dev)
Dependency Relation
imports 7 packages, and imported by one package
Involved Source Files
Package mathjax converts TeX math to SVG without a JavaScript runtime.
Its compatibility target is the custom MathJax 3.2.2 component embedded by
D2. Render uses that component's display-mode, 16-pixel em, 8-pixel ex, and
uncached-font-path defaults.
options.go
Package-Level Type Names (total 2)
FontCacheMode controls how glyph paths are represented in rendered SVG.
MathJax-go initially supports FontCacheNone, which is the mode used by D2's
frozen MathJax 3.2.2 component.
const FontCacheNone
Options controls TeX-to-SVG conversion.
Display selects display math when true and inline math when false.
Em is the em size in pixels used to resolve relative lengths.
Ex is the ex size in pixels used to resolve relative lengths and report
the serialized SVG dimensions.
FontCache controls SVG glyph reuse. Only FontCacheNone is supported.
func DefaultOptions() Options
func RenderWithOptions(tex string, options Options) (string, error)
Package-Level Functions (total 4)
DefaultOptions returns the options used by D2's frozen MathJax 3.2.2
integration.
Measure renders TeX with DefaultOptions and returns its rounded-up width and
height in pixels. It preserves D2's MathJax 3.2.2 measurement contract: the
serialized SVG dimensions are expressed in ex units and one ex is 8 pixels.
Render converts TeX to a bare SVG element using DefaultOptions. TeX syntax
errors are represented by MathJax-compatible merror SVG; non-nil errors
report an invalid option or an internal conversion failure.
RenderWithOptions converts TeX to a bare SVG element. The returned string is
the equivalent of the inner HTML of MathJax's mjx-container. TeX syntax
errors are represented by MathJax-compatible merror SVG.
Package-Level Constants (total 2)
CompatibilityVersion is the upstream MathJax version whose behavior this
module preserves.
FontCacheNone emits an independent SVG path for each glyph occurrence.
![]() |
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |