By default, math output is not accessible to screen readers. To enable accessibility, you must provide a speech-rule-engine (SRE) instance in the accessibility.sre option. This adds assistive-mml to the mjx-container, allowing screen readers to interpret math (e.g., reading $x^y$ as "x Superscript y").
Browser Usage (Synchronous)
Import loadSre from mathpix-markdown-it/lib/sre/sre-browser and pass its result to the options object.
Node.js Usage (Asynchronous)
Import loadSreAsync from mathpix-markdown-it/lib/sre/sre-node and await its result before calling markdownToHTML.
// Browser Example
import { MathpixMarkdownModel } from "mathpix-markdown-it";
import { loadSre } from "mathpix-markdown-it/lib/sre/sre-browser";
const html = MathpixMarkdownModel.markdownToHTML("$x^y$", {
accessibility: {
sre: loadSre()
},
});
// Node.js Example
const { MathpixMarkdownModel } = require('mathpix-markdown-it');
const { loadSreAsync } = require('mathpix-markdown-it/lib/sre/sre-node');
(async() => {
const html = MathpixMarkdownModel.markdownToHTML("$x^y$", {
accessibility: {
sre: await loadSreAsync()
},
});
})();