« get me outta code hell

data, yaml: catch commentary artist ref errors - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/composite
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-11-14 22:49:51 -0400
committer(quasar) nebula <qznebula@protonmail.com>2023-11-14 23:32:24 -0400
commit362dc0619b93d74ad34df1bfbfd9ebc632fa5156 (patch)
tree79331efb4387ee03aae6ad6da54bd8e5896189b4 /src/data/composite
parent09a4af31a3f8207dfe114926b0dbf27eeddf7de9 (diff)
data, yaml: catch commentary artist ref errors
Diffstat (limited to 'src/data/composite')
-rw-r--r--src/data/composite/wiki-data/withParsedCommentaryEntries.js23
1 files changed, 1 insertions, 22 deletions
diff --git a/src/data/composite/wiki-data/withParsedCommentaryEntries.js b/src/data/composite/wiki-data/withParsedCommentaryEntries.js
index 5bd72dc9..9e33cdac 100644
--- a/src/data/composite/wiki-data/withParsedCommentaryEntries.js
+++ b/src/data/composite/wiki-data/withParsedCommentaryEntries.js
@@ -2,33 +2,12 @@ import {input, templateCompositeFrom} from '#composite';
 import find from '#find';
 import {stitchArrays} from '#sugar';
 import {isCommentary} from '#validators';
+import {commentaryRegex} from '#wiki-data';
 
 import {fillMissingListItems, withPropertiesFromList} from '#composite/data';
 
 import withResolvedReferenceList from './withResolvedReferenceList.js';
 
-// Matches in roughly the format:
-//
-//    <i>artistReference:</i> (annotation, date)
-//
-// where capturing group "annotation" can be any text at all, except that the
-// last entry (past a comma or the only content within parentheses), if parsed
-// as a date, is the capturing group "date". "Parsing as a date" means one of
-// these formats:
-//
-//   * "25 December 2019" - one or two number digits, followed by any text,
-//     followed by four number digits
-//   * "12/25/2019" - one or two number digits, a slash, one or two number
-//     digits, a slash, and two to four number digits
-//
-// The artist reference can optionally be boldface (in <b></b>), which will be
-// captured as non-null in "boldfaceArtist". Otherwise it is all the characters
-// between <i> and </i> and is captured in "artistReference" and is either the
-// name of an artist or an "artist:directory"-style reference.
-//
-export const commentaryRegex =
-  /^<i>(?<boldfaceArtist><b>)?(?<artistReference>.+):(?:<\/b>)?<\/i>(?: \((?<annotation>(?:.*?(?=[,)]))*?)(?:,? ?(?<date>[0-9]{1,2} [^,]*[0-9]{4,4}|[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{2,4}))?\))?/gm;
-
 export default templateCompositeFrom({
   annotation: `withParsedCommentaryEntries`,