examples/

directory
v0.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2026 License: Apache-2.0, MIT

README

Examples

  • mygo/ shows Untie in a native MyGo desktop window.
  • mathml/ converts TeX or Typst to deterministic Presentation MathML.
  • svg/ exports a formula as a deterministic standalone SVG.
  • png/ rasterizes a formula to an antialiased PNG.

MathML

Write Presentation MathML to standard output:

go run ./examples/mathml \
  -source '\frac{-b \pm \sqrt{b^2-4ac}}{2a}'

Use -dialect typst for Typst input, -mode inline for inline math, or -out formula.xml to write a file. This example needs no font.

SVG

Write an SVG to a file:

go run ./examples/svg \
  -source '\frac{-b \pm \sqrt{b^2-4ac}}{2a}' \
  -out formula.svg

Omit -out to write the SVG document to standard output. Use -dialect typst to change the input language, or -mode inline for inline layout.

PNG

Write a two-pixel-per-unit PNG with a white background:

go run ./examples/png \
  -source '\sum_{k=1}^{n} k^2' \
  -scale 2 \
  -out formula.png

Omit -out to write the PNG stream to standard output. Pass -transparent to keep the background transparent. Both examples use testdata/upstream/fonts/NewCMMath-Book.otf by default; override it with -font.

Directories

Path Synopsis
internal
example
Package example provides shared command-line setup for the exporter examples.
Package example provides shared command-line setup for the exporter examples.
Command mathml converts TeX or Typst math to deterministic Presentation MathML.
Command mathml converts TeX or Typst math to deterministic Presentation MathML.
Command png renders one formula as an antialiased PNG image.
Command png renders one formula as an antialiased PNG image.
Command svg renders one formula as a standalone SVG document.
Command svg renders one formula as a standalone SVG document.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL