Keep prose citations inline
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
e71a7e22e1
commit
34eef6ec6b
2 changed files with 8 additions and 13 deletions
|
|
@ -96,10 +96,8 @@ function formatCitationCluster(nums) {
|
|||
export function normalizeMarkdownText(text) {
|
||||
return stripOrphanMarkdownMarkers(normalizeTableSourceCitationCells(String(text || '')
|
||||
.replace(/\r\n/g, '\n')
|
||||
.replace(/(\[(?:\d+\s*,\s*)*\d+\])\s*[-–—]\s*/g, '$1\n- ')
|
||||
.replace(/([.!?])\s*[-–—]\s+(\*\*)?/g, '$1\n- $2')
|
||||
.replace(/(:)\s*[-–—]\s+(\*\*)?/g, '$1\n- $2')
|
||||
.replace(/(\[(?:\d+\s*,\s*)*\d+\]\.)\s+(\d+\.\s+[A-Z][A-Za-z][^\n]{0,80})/g, '$1\n$2')
|
||||
.replace(/([.!?])\s+(\d+\.\s+[A-Z][A-Za-z][^\n]{0,80})/g, '$1\n$2')
|
||||
.replace(/([^\n])\s+(#{1,4}\s+)/g, '$1\n\n$2')
|
||||
.replace(/(#{1,4}\s+[^\n]+?)\s+(-\s+)/g, '$1\n\n$2')
|
||||
|
|
|
|||
|
|
@ -105,12 +105,11 @@ test('normalizes old saved assistant answer formatting', async () => {
|
|||
assert.match(html, /Key Differences/);
|
||||
});
|
||||
|
||||
test('repairs smashed admission bullet list after citations', async () => {
|
||||
test('does not turn citation-delimited prose into a list', async () => {
|
||||
const { renderAssistantMarkdown } = await loadCitationModule();
|
||||
const html = renderAssistantMarkdown('Admission is indicated for: Apnoea [1, 2]- **Persistent oxygen saturation <90%** [1, 2]- **Severe respiratory distress** [1]', sources);
|
||||
assert.match(html, /<li><strong>Persistent oxygen saturation <90%<\/strong>/);
|
||||
assert.match(html, /<li><strong>Severe respiratory distress<\/strong>/);
|
||||
assert.doesNotMatch(html, /\]-/);
|
||||
const html = renderAssistantMarkdown('Admission is indicated for: Apnoea [1, 2]- **Persistent oxygen saturation <90%** [1, 2].', sources);
|
||||
assert.match(html, /<\/a>- <strong>Persistent oxygen saturation <90%<\/strong>/);
|
||||
assert.doesNotMatch(html, /<ul>/);
|
||||
});
|
||||
|
||||
test('keeps citations inline before clinical terms', async () => {
|
||||
|
|
@ -120,13 +119,11 @@ test('keeps citations inline before clinical terms', async () => {
|
|||
assert.doesNotMatch(html, /<\/a><br>\s*and dehydration/);
|
||||
});
|
||||
|
||||
test('repairs smashed head injury red flag bullets after citation clusters', async () => {
|
||||
test('keeps citation-delimited clinical prose inline', async () => {
|
||||
const { renderAssistantMarkdown } = await loadCitationModule();
|
||||
const html = renderAssistantMarkdown('CT is indicated for: [1, 2, 3]- Focal neurologic deficits [1]- Signs of skull fracture [2]- Recurrent vomiting [3]', sources);
|
||||
assert.match(html, /<li>Focal neurologic deficits/);
|
||||
assert.match(html, /<li>Signs of skull fracture/);
|
||||
assert.match(html, /<li>Recurrent vomiting/);
|
||||
assert.doesNotMatch(html, /\]-/);
|
||||
const html = renderAssistantMarkdown('CT is indicated for: [1, 2, 3]- Focal neurologic deficits [1].', sources);
|
||||
assert.match(html, /<\/a>- Focal neurologic deficits/);
|
||||
assert.doesNotMatch(html, /<br>|<ul>/);
|
||||
});
|
||||
|
||||
test('preserves code block contents without creating citation links inside code', async () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue