(latexCode, options = {})
| 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 | })(); |
nothing calls this directly
no test coverage detected