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

Function formatStreamingMessage

apps/chat/src/utils/markdown.js:212–233  ·  view source on GitHub ↗
(content)

Source from the content-addressed store, hash-verified

210};
211
212export const formatStreamingMessage = (content) => {
213 if (!content) return "";
214
215 try {
216 let textContent = String(content || "");
217
218 textContent = textContent.trim();
219
220 textContent = textContent.replace(/\n{3,}/g, "\n\n");
221
222 textContent = textContent.replace(
223 /([^`\n])([ ]{2,})([^`\n])/g,
224 "$1 $3",
225 );
226
227 const html = marked.parse(textContent, { async: false });
228 return sanitizeRenderedHtml(renderMath(html));
229 } catch (error) {
230 console.error("Streaming markdown rendering error:", error);
231 return escapeHtml(String(content));
232 }
233};

Callers 2

TypewriterEffectFunction · 0.90
test-markdown.jsFile · 0.90

Calls 6

sanitizeRenderedHtmlFunction · 0.85
renderMathFunction · 0.85
parseMethod · 0.80
errorMethod · 0.80
escapeHtmlFunction · 0.70
replaceMethod · 0.65

Tested by

no test coverage detected