MCPcopy Create free account
hub / github.com/Yorick-Ryu/deep-share / convertLatexToMathML

Function convertLatexToMathML

scripts/formulaConverter.js:122–144  ·  view source on GitHub ↗
(latexCode, options = {})

Source from the content-addressed store, hash-verified

120 }
121
122 async function convertLatexToMathML(latexCode, options = {}) {
123 const displayMode = options.displayMode !== false;
124 const engine = options.engine || 'mathjax';
125
126 if (engine === 'katex') {
127 await waitForKaTeX();
128 const res = convertWithKaTeX(latexCode, displayMode);
129 if (res.success) return res.mathml;
130 // fallback to MathJax
131 await waitForMathJax();
132 const mj = convertWithMathJax(latexCode, displayMode);
133 return mj.success ? mj.mathml : mj.fallback || latexCode;
134 }
135
136 // default MathJax
137 await waitForMathJax();
138 const res = convertWithMathJax(latexCode, displayMode);
139 if (res.success) return res.mathml;
140 // fallback to KaTeX
141 await waitForKaTeX();
142 const kt = convertWithKaTeX(latexCode, displayMode);
143 return kt.success ? kt.mathml : kt.fallback || latexCode;
144 }
145
146 return { convertLatexToMathML };
147})();

Callers

nothing calls this directly

Calls 4

waitForKaTeXFunction · 0.85
convertWithKaTeXFunction · 0.85
waitForMathJaxFunction · 0.85
convertWithMathJaxFunction · 0.85

Tested by

no test coverage detected