« get me outta code hell

wiki-data, yaml: artistless content entries "@@ annotation" - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2026-01-31 17:13:26 -0400
committer(quasar) nebula <qznebula@protonmail.com>2026-01-31 17:13:26 -0400
commit3205d96a9095e2419ded46a30ed26b714ad0395f (patch)
treec6bfc2c403b1ae630891486758c48fab4e0375db /src
parentb45c33241cbb559e493fb19a8e775326d69b3d6f (diff)
wiki-data, yaml: artistless content entries "@@ annotation"
Diffstat (limited to 'src')
-rw-r--r--src/common-util/wiki-data.js21
-rw-r--r--src/data/yaml.js78
2 files changed, 59 insertions, 40 deletions
diff --git a/src/common-util/wiki-data.js b/src/common-util/wiki-data.js
index e92a80d5..de34a807 100644
--- a/src/common-util/wiki-data.js
+++ b/src/common-util/wiki-data.js
@@ -83,7 +83,16 @@ const dateRegex = groupName =>
   String.raw`)`;
 
 const contentEntryHeadingRegexRaw =
-  String.raw`^<i>(?<artists>.+?):<\/i>(?: \((?<annotation>.*)\))?$`;
+  String.raw`^(?:` +
+    String.raw`(?:` +
+      String.raw`<i>(?<artists>.+?):<\/i>` +
+      String.raw`(?: \((?<annotation1>.*)\))?` +
+    String.raw`)` +
+    String.raw`|` +
+    String.raw`(?:` +
+      String.raw`@@ (?<annotation2>.*)` +
+    String.raw`)` +
+  String.raw`)$`;
 
 const contentEntryHeadingRegex =
   new RegExp(contentEntryHeadingRegexRaw, 'gm');
@@ -121,7 +130,15 @@ export function* matchContentEntries(sourceText) {
       yield workingEntry;
     }
 
-    workingEntry = {...headingMatch.groups};
+    workingEntry = {
+      artists:
+        headingMatch.groups.artists ?? null,
+
+      annotation:
+        headingMatch.groups.annotation1 ??
+        headingMatch.groups.annotation2 ??
+        null,
+    };
 
     if (workingEntry.annotation) {
       const annotationTailMatch =
diff --git a/src/data/yaml.js b/src/data/yaml.js
index 85c05b93..ddf4481d 100644
--- a/src/data/yaml.js
+++ b/src/data/yaml.js
@@ -942,47 +942,49 @@ export function parseContentEntriesFromSourceText(thingClass, sourceText, {subdo
   function map(matchEntry) {
     let artistText = null, artistReferences = null;
 
-    const artistTextNodes =
-      Array.from(
-        splitContentNodesAround(
-          parseContentNodes(matchEntry.artists),
-          /\|/g));
-
-    const separatorIndices =
-      artistTextNodes
-        .filter(node => node.type === 'separator')
-        .map(node => artistTextNodes.indexOf(node));
-
-    if (empty(separatorIndices)) {
-      if (artistTextNodes.length === 1 && artistTextNodes[0].type === 'text') {
-        artistReferences = matchEntry.artists;
+    if (matchEntry.artists) {
+      const artistTextNodes =
+        Array.from(
+          splitContentNodesAround(
+            parseContentNodes(matchEntry.artists),
+            /\|/g));
+
+      const separatorIndices =
+        artistTextNodes
+          .filter(node => node.type === 'separator')
+          .map(node => artistTextNodes.indexOf(node));
+
+      if (empty(separatorIndices)) {
+        if (artistTextNodes.length === 1 && artistTextNodes[0].type === 'text') {
+          artistReferences = matchEntry.artists;
+        } else {
+          artistText = matchEntry.artists;
+        }
       } else {
-        artistText = matchEntry.artists;
+        const firstSeparatorIndex =
+          separatorIndices.at(0);
+
+        const secondSeparatorIndex =
+          separatorIndices.at(1) ??
+          artistTextNodes.length;
+
+        artistReferences =
+          matchEntry.artists.slice(
+            artistTextNodes.at(0).i,
+            artistTextNodes.at(firstSeparatorIndex - 1).iEnd);
+
+        artistText =
+          matchEntry.artists.slice(
+            artistTextNodes.at(firstSeparatorIndex).iEnd,
+            artistTextNodes.at(secondSeparatorIndex - 1).iEnd);
       }
-    } else {
-      const firstSeparatorIndex =
-        separatorIndices.at(0);
-
-      const secondSeparatorIndex =
-        separatorIndices.at(1) ??
-        artistTextNodes.length;
-
-      artistReferences =
-        matchEntry.artists.slice(
-          artistTextNodes.at(0).i,
-          artistTextNodes.at(firstSeparatorIndex - 1).iEnd);
-
-      artistText =
-        matchEntry.artists.slice(
-          artistTextNodes.at(firstSeparatorIndex).iEnd,
-          artistTextNodes.at(secondSeparatorIndex - 1).iEnd);
-    }
 
-    if (artistReferences) {
-      artistReferences =
-        artistReferences
-          .split(',')
-          .map(ref => ref.trim());
+      if (artistReferences) {
+        artistReferences =
+          artistReferences
+            .split(',')
+            .map(ref => ref.trim());
+      }
     }
 
     return {