From dc0d479d6698bf1db3f5181f48332da26ebd47f7 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 26 Jan 2026 19:52:39 -0400 Subject: data, content: Contribution.artistText --- src/data/yaml.js | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'src/data/yaml.js') diff --git a/src/data/yaml.js b/src/data/yaml.js index 50496c00..2afaffb5 100644 --- a/src/data/yaml.js +++ b/src/data/yaml.js @@ -646,6 +646,9 @@ export const extractAccentRegex = export const extractPrefixAccentRegex = /^(?:\((?.*)\) )?(?
.*?)$/; +export const asNameRegex = + /^as (?\S.+?)(?:(?<=\S)[,:] | +- |$)(?: *(?.*))?$/; + // TODO: Should this fit better within actual YAML loading infrastructure?? export function parseArrayEntries(entries, mapFn) { // If this isn't something we can parse, just return it as-is. @@ -679,12 +682,14 @@ export function parseContributors(entries) { if (typeof item === 'object' && item['Who']) return { artist: item['Who'], + artistText: item['As'] ?? null, annotation: item['What'] ?? null, }; if (typeof item === 'object' && item['Artist']) return { artist: item['Artist'], + artistText: item['Artist Text'] ?? null, annotation: item['Annotation'] ?? null, countInContributionTotals: item['Count In Contribution Totals'] ?? null, @@ -693,13 +698,28 @@ export function parseContributors(entries) { if (typeof item !== 'string') return item; - const match = item.match(extractAccentRegex); + let match; + + match = item.match(extractAccentRegex); if (!match) return item; - return { - artist: match.groups.main, - annotation: match.groups.accent ?? null, - }; + const {accent} = match.groups; + + let artist = match.groups.main; + let artistText = null; + let annotation = null; + + if (accent) { + match = accent.match(asNameRegex); + if (match) { + artistText = match.groups.name; + annotation = match.groups.annotation ?? null; + } else { + annotation = accent; + } + } + + return {artist, artistText, annotation}; }); } -- cgit 1.3.0-6-gf8a5