discourse/plugins/discourse-math/assets/javascripts/lib/load-katex.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

29 lines
629 B
JavaScript
Vendored

import {
getKaTeX,
loadCopyTex,
loadKaTeX as loadKaTeXBundle,
loadMhchem,
} from "discourse/plugins/discourse-math/lib/katex-bundle";
let basePromise;
let mhchemPromise;
let copyTexPromise;
export default async function loadKaTeX(options = {}) {
if (!basePromise) {
basePromise = loadKaTeXBundle();
}
await basePromise;
if (options.enableMhchem && !mhchemPromise) {
mhchemPromise = loadMhchem();
}
if (options.enableCopyTex && !copyTexPromise) {
copyTexPromise = loadCopyTex();
}
await Promise.all([mhchemPromise, copyTexPromise].filter(Boolean));
return getKaTeX() ?? window.katex;
}