MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / renderAnswerWithCitations

Function renderAnswerWithCitations

deployments/desktop/static/desktop.js:4210–4223  ·  view source on GitHub ↗
(text, citations = [])

Source from the content-addressed store, hash-verified

4208 }
4209
4210 function renderAnswerWithCitations(text, citations = []) {
4211 const refs = new Map(citations.map((citation) => [String(citation.index), citation]));
4212 const escaped = escapeHtml(text || "");
4213 if (!escaped) return `<p>${escapeHtml(ui().chat.generating)}</p>`;
4214 const linked = escaped.replace(/\[(\d{1,3})\]/g, (match, index) => {
4215 if (!refs.has(String(index))) return match;
4216 const citation = refs.get(String(index));
4217 return `<button type="button" class="citation-ref" data-citation-index="${index}" title="${escapeHtml(citation.title)}">[${index}]</button>`;
4218 }).replace(/\*\*([^*\n]+?)\*\*/g, "<strong>$1</strong>");
4219 return linked
4220 .split(/\n{2,}/)
4221 .map((block) => `<p>${block.replace(/\n/g, "<br>")}</p>`)
4222 .join("");
4223 }
4224
4225 function routingLabel(reason) {
4226 return ui().chat.routing[reason] || reason || "";

Callers 4

renderChatMessagesFunction · 0.85
streamAnswerTextFunction · 0.85
processFrameFunction · 0.85
streamWikiAskFunction · 0.85

Calls 3

uiFunction · 0.85
getMethod · 0.80
escapeHtmlFunction · 0.70

Tested by

no test coverage detected