This commit is contained in:
2026-07-31 15:07:12 +08:00
parent 3448ffe961
commit 9d92f86f08
49 changed files with 13833 additions and 1265 deletions

View File

@@ -0,0 +1,35 @@
import {
extractFigureNumbersFromText,
paragraphMentionsFigureNumber,
parseFigureNumberFromTitle,
findFirstAmIdForFigureNumber
} from '../src/utils/manuscriptMediaReferences.js';
const samples = [
'Figure 3A and Figure 3B.',
'as shown in Figure 3A and Figure 3B.',
'See Fig. 3 and Fig. 3A',
'as shown in <blue>Figure 3A</blue> and <blue>Figure 3B</blue>.'
];
for (const s of samples) {
console.log(JSON.stringify(s), '=>', extractFigureNumbersFromText(s), 'mentions3', paragraphMentionsFigureNumber(s, 3));
}
console.log(
'title',
parseFigureNumberFromTitle('<span style="color:#d25a5a">Figure 3 Co-occurrence map</span>')
);
console.log(
'find',
findFirstAmIdForFigureNumber(
[
{ am_id: 1, type: 0, content: 'hello' },
{
am_id: 146120,
type: 0,
content: 'as shown in <blue>Figure 3A</blue> and <blue>Figure 3B</blue>.'
},
{ am_id: 3, type: 1, content: '', ami_id: 99 }
],
3
)
);