From f43c4ba77f5598d5234b21fcd03fa7788b17afe5 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 25 Dec 2024 17:40:09 -0400 Subject: data: amorphize annotated reference lists --- src/data/yaml.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'src/data/yaml.js') diff --git a/src/data/yaml.js b/src/data/yaml.js index f7c36b89..0bc2e298 100644 --- a/src/data/yaml.js +++ b/src/data/yaml.js @@ -569,27 +569,31 @@ export function parseContributionPresets(list) { }); } -export function parseAnnotatedReferences(entries) { +export function parseAnnotatedReferences(entries, { + referenceField = 'References', + annotationField = 'Annotation', + referenceProperty = 'reference', + annotationProperty = 'annotation', +} = {}) { return parseArrayEntries(entries, item => { - if (typeof item === 'object' && item['References']) + if (typeof item === 'object' && item[referenceField]) return { - reference: item['References'], - annotation: item['Annotation'] ?? null, + [referenceProperty]: item[referenceField], + [annotationProperty]: item[annotationField] ?? null, }; if (typeof item !== 'string') return item; const match = item.match(extractAccentRegex); - if (!match) { + if (!match) return { - reference: item, - annotation: null, - } - } + [referenceProperty]: item, + [annotationProperty]: null, + }; return { - reference: match.groups.main, - annotation: match.groups.accent, + [referenceProperty]: match.groups.main, + [annotationProperty]: match.groups.accent ?? null, }; }); } -- cgit 1.3.0-6-gf8a5