satteri-mathml
v0.1.1
Published
Sätteri plugin that renders LaTeX math to native MathML via math-core
Maintainers
Readme
satteri-mathml
A Sätteri plugin that renders LaTeX math to native MathML using math-core.
No client-side JavaScript. Output is plain MathML rendered by the browser.
Install
pnpm add satteri-mathmlUsage
Astro
// astro.config.mjs
import { defineConfig } from "astro/config";
import { satteri } from "@astrojs/markdown-satteri";
import satteriMathml from "satteri-mathml";
export default defineConfig({
markdown: {
processor: satteri({
features: { math: true },
mdastPlugins: [satteriMathml()],
}),
},
});Import the styles once in your layout:
import "satteri-mathml/style.css";Standalone
import { markdownToHtml } from "satteri";
import satteriMathml from "satteri-mathml";
const { html } = markdownToHtml("$x^2$", {
features: { math: true },
mdastPlugins: [satteriMathml()],
});Options
| Option | Type | Default | Description |
| -------------- | ------------------------ | ------- | --------------------------------------------------------------------------------------- |
| macros | Record<string, string> | {} | Custom macros, e.g. { "dd": "\\mathrm{d}" } |
| throwOnError | boolean | false | By default, invalid LaTeX renders as a fallback. Set to true to fail the build instead. |
Other options are passed to math-core.
Styles
satteri-mathml/style.css: MathML fixes + NewCM Math font (recommended)satteri-mathml/mathmlfixes.css: fixes only, bring your own math font
Invalid formulas render as <code class="math-error"> with the error message in title.
License
MIT for the plugin code.
Bundled third-party assets keep their own licenses:
mathmlfixes.css: MIT, seeassets/LICENSE-math-core.txtNewCMMath-Book.woff2: GUST Font License, seeassets/LICENSE-NewCM.txt
