diff options
Diffstat (limited to 'src/data/yaml.js')
-rw-r--r-- | src/data/yaml.js | 26 |
1 files changed, 15 insertions, 11 deletions
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, }; }); } |