Rejoin detached clinical citations
All checks were successful
Forgejo Android APK / Build signed APK (push) Successful in 1m50s
All checks were successful
Forgejo Android APK / Build signed APK (push) Successful in 1m50s
This commit is contained in:
parent
34eef6ec6b
commit
e4dacbaf09
2 changed files with 8 additions and 0 deletions
|
|
@ -96,6 +96,7 @@ function formatCitationCluster(nums) {
|
|||
export function normalizeMarkdownText(text) {
|
||||
return stripOrphanMarkdownMarkers(normalizeTableSourceCitationCells(String(text || '')
|
||||
.replace(/\r\n/g, '\n')
|
||||
.replace(/([^\n])\n+\s*(\[(?:\d+\s*,\s*)*\d+\])\s*(?:\n+\s*([.,;:]))?(?=\s*(?:\n|$))/g, '$1 $2$3')
|
||||
.replace(/([.!?])\s*[-–—]\s+(\*\*)?/g, '$1\n- $2')
|
||||
.replace(/(:)\s*[-–—]\s+(\*\*)?/g, '$1\n- $2')
|
||||
.replace(/([.!?])\s+(\d+\.\s+[A-Z][A-Za-z][^\n]{0,80})/g, '$1\n$2')
|
||||
|
|
|
|||
|
|
@ -112,6 +112,13 @@ test('does not turn citation-delimited prose into a list', async () => {
|
|||
assert.doesNotMatch(html, /<ul>/);
|
||||
});
|
||||
|
||||
test('joins a citation-only paragraph back to its claim', async () => {
|
||||
const { renderAssistantMarkdown } = await loadCitationModule();
|
||||
const html = renderAssistantMarkdown('Acquired hypothyroidism is uncommon.\n\n[1, 2]\n\n.\n\n- Next point', sources);
|
||||
assert.match(html, /uncommon\. <a class="assistant-cite"[^>]*>src<\/a> <a class="assistant-cite"[^>]*>src<\/a>\./);
|
||||
assert.doesNotMatch(html, /<p>\s*<a class="assistant-cite"/);
|
||||
});
|
||||
|
||||
test('keeps citations inline before clinical terms', async () => {
|
||||
const { renderAssistantMarkdown } = await loadCitationModule();
|
||||
const html = renderAssistantMarkdown('Assess for lethargy [1] and dehydration [2].', sources);
|
||||
|
|
|
|||
Loading…
Reference in a new issue