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

Function convertWithKaTeX

scripts/formulaConverter.js:102–120  ·  view source on GitHub ↗
(latexCode, displayMode)

Source from the content-addressed store, hash-verified

100 }
101
102 function convertWithKaTeX(latexCode, displayMode) {
103 try {
104 if (typeof katex !== 'undefined') {
105 const container = document.createElement('div');
106 katex.render(latexCode, container, {
107 output: 'mathml',
108 throwOnError: false,
109 displayMode: displayMode
110 });
111 const mathmlElement = container.querySelector('math');
112 if (mathmlElement) {
113 return { success: true, mathml: mathmlElement.outerHTML };
114 }
115 }
116 return { success: false, error: 'KaTeX not available', fallback: latexCode };
117 } catch (error) {
118 return { success: false, error: error.message, fallback: latexCode };
119 }
120 }
121
122 async function convertLatexToMathML(latexCode, options = {}) {
123 const displayMode = options.displayMode !== false;

Callers 1

convertLatexToMathMLFunction · 0.85

Calls 1

renderMethod · 0.45

Tested by

no test coverage detected