MCPcopy Create free account
hub / github.com/pollinations/pollinations / renderMath

Function renderMath

apps/chat/src/utils/markdown.js:144–168  ·  view source on GitHub ↗
(html)

Source from the content-addressed store, hash-verified

142}).use(markdownitHighlightjs);
143
144const renderMath = (html) => {
145 if (typeof document === "undefined") {
146 return html;
147 }
148
149 const div = document.createElement("div");
150 div.innerHTML = html;
151
152 try {
153 renderMathInElement(div, {
154 delimiters: [
155 { left: "$$", right: "$$", display: true },
156 { left: "$", right: "$", display: false },
157 { left: "\\[", right: "\\]", display: true },
158 { left: "\\(", right: "\\)", display: false },
159 ],
160 throwOnError: false,
161 katex,
162 });
163 } catch (error) {
164 console.error("KaTeX rendering error:", error);
165 }
166
167 return div.innerHTML;
168};
169
170export const formatMessage = (content) => {
171 if (!content) return "";

Callers 2

formatMessageFunction · 0.85
formatStreamingMessageFunction · 0.85

Calls 1

errorMethod · 0.80

Tested by

no test coverage detected