discourse/plugins/discourse-math/assets/javascripts/lib/load-mathjax.js
Sam d31ca17c57
FEATURE: update mathjax to version 4.1 (#36814)
This upgrades to Mathjax 4.1 and latest katex
Implement rich text composer support for math
Adds support for /( )/ and /[ /] which was missing and very common now 
Removes math javascript from our repo

---------

Co-authored-by: Mark McClure <mcmcclur@unca.edu>
2026-01-09 08:24:31 +11:00

19 lines
575 B
JavaScript
Vendored

import {
getMathJax,
loadOutput,
} from "discourse/plugins/discourse-math/lib/mathjax-bundle";
// MathJax can only be initialized once per page load with a single output format.
// The output format is locked to whichever value is passed on the first call.
let outputPromise;
export default async function loadMathJax(options = {}) {
const output = options.output === "svg" ? "svg" : "html";
if (!outputPromise) {
outputPromise = loadOutput(output);
}
await outputPromise;
await window.MathJax.startup.promise;
return getMathJax() ?? window.MathJax;
}