Render escaped clinical citations as links
All checks were successful
Forgejo Android APK / Build signed APK (push) Successful in 1m49s
All checks were successful
Forgejo Android APK / Build signed APK (push) Successful in 1m49s
This commit is contained in:
parent
e4dacbaf09
commit
491f5e02b7
2 changed files with 9 additions and 1 deletions
|
|
@ -6,7 +6,7 @@ export function renderAssistantMarkdown(md, sources, options) {
|
|||
codeBlocks.push({ lang: (lang || '').toLowerCase(), code: code });
|
||||
return '\n@@CODEBLOCK_' + idx + '@@\n';
|
||||
});
|
||||
text = stripOrphanMarkdownMarkers(normalizeMarkdownText(text));
|
||||
text = stripOrphanMarkdownMarkers(normalizeMarkdownText(text.replace(/\\\[((?:\d+\s*,\s*)*\d+)\\\]/g, '[$1]')));
|
||||
text = renderLatexText(text, opts.katex);
|
||||
text = normalizeAdjacentCitationClusters(text, sources || []);
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,14 @@ test('renders citation clusters as links to matching source cards', async () =>
|
|||
assert.match(html, /<a class="assistant-cite"[^>]*>src<\/a> <a class="assistant-cite"[^>]*>src<\/a>/);
|
||||
});
|
||||
|
||||
test('renders escaped citation tokens as source links, not display math', async () => {
|
||||
const { renderAssistantMarkdown } = await loadCitationModule();
|
||||
const katex = { renderToString: function () { throw new Error('citation sent to KaTeX'); } };
|
||||
const html = renderAssistantMarkdown('Acquired hypothyroidism is uncommon. \\[1, 2\\].', sources, { katex });
|
||||
assert.match(html, /<a class="assistant-cite"[^>]*>src<\/a> <a class="assistant-cite"[^>]*>src<\/a>/);
|
||||
assert.doesNotMatch(html, /katex-display/);
|
||||
});
|
||||
|
||||
test('can render citation labels as numbers for PDF export', async () => {
|
||||
const { renderAssistantMarkdown } = await loadCitationModule();
|
||||
const html = renderAssistantMarkdown('Give magnesium for severe exacerbation [1, 2].', sources, { citationLabel: 'number' });
|
||||
|
|
|
|||
Loading…
Reference in a new issue