« get me outta code hell

content: transformContent: move replacerSpec into #replacer - 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>2024-02-16 18:01:53 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-02-17 17:09:18 -0400
commit74ded573b9e24b120573a3f5319de7501b17a759 (patch)
treeb024dcde91c271f468249307aede1080a182d85a /src
parente4b4359f674a629b32f74d3a8e39e88b8fada656 (diff)
content: transformContent: move replacerSpec into #replacer
Diffstat (limited to 'src')
-rw-r--r--src/content/dependencies/transformContent.js138
-rw-r--r--src/util/replacer.js136
2 files changed, 137 insertions, 137 deletions
diff --git a/src/content/dependencies/transformContent.js b/src/content/dependencies/transformContent.js
index 760b509a..1bba16e3 100644
--- a/src/content/dependencies/transformContent.js
+++ b/src/content/dependencies/transformContent.js
@@ -1,144 +1,8 @@
 import {bindFind} from '#find';
-import {parseInput} from '#replacer';
+import {replacerSpec, parseInput} from '#replacer';
 
 import {Marked} from 'marked';
 
-export const replacerSpec = {
-  'album': {
-    find: 'album',
-    link: 'linkAlbum',
-  },
-
-  'album-commentary': {
-    find: 'album',
-    link: 'linkAlbumCommentary',
-  },
-
-  'album-gallery': {
-    find: 'album',
-    link: 'linkAlbumGallery',
-  },
-
-  'artist': {
-    find: 'artist',
-    link: 'linkArtist',
-  },
-
-  'artist-gallery': {
-    find: 'artist',
-    link: 'linkArtistGallery',
-  },
-
-  'commentary-index': {
-    find: null,
-    link: 'linkCommentaryIndex',
-  },
-
-  'date': {
-    find: null,
-    value: (ref) => new Date(ref),
-    html: (date, {html, language}) =>
-      html.tag('time',
-        {datetime: date.toUTCString()},
-        language.formatDate(date)),
-  },
-
-  'flash-index': {
-    find: null,
-    link: 'linkFlashIndex',
-  },
-
-  'flash': {
-    find: 'flash',
-    link: 'linkFlash',
-    transformName(name, node, input) {
-      const nextCharacter = input[node.iEnd];
-      const lastCharacter = name[name.length - 1];
-      if (![' ', '\n', '<'].includes(nextCharacter) && lastCharacter === '.') {
-        return name.slice(0, -1);
-      } else {
-        return name;
-      }
-    },
-  },
-
-  'flash-act': {
-    find: 'flashAct',
-    link: 'linkFlashAct',
-  },
-
-  'group': {
-    find: 'group',
-    link: 'linkGroup',
-  },
-
-  'group-gallery': {
-    find: 'group',
-    link: 'linkGroupGallery',
-  },
-
-  'home': {
-    find: null,
-    link: 'linkWikiHome',
-  },
-
-  'listing-index': {
-    find: null,
-    link: 'linkListingIndex',
-  },
-
-  'listing': {
-    find: 'listing',
-    link: 'linkListing',
-  },
-
-  'media': {
-    find: null,
-    link: 'linkPathFromMedia',
-  },
-
-  'news-index': {
-    find: null,
-    link: 'linkNewsIndex',
-  },
-
-  'news-entry': {
-    find: 'newsEntry',
-    link: 'linkNewsEntry',
-  },
-
-  'root': {
-    find: null,
-    link: 'linkPathFromRoot',
-  },
-
-  'site': {
-    find: null,
-    link: 'linkPathFromSite',
-  },
-
-  'static': {
-    find: 'staticPage',
-    link: 'linkStaticPage',
-  },
-
-  'string': {
-    find: null,
-    value: (ref) => ref,
-    html: (ref, {language, args}) => language.$(ref, args),
-  },
-
-  'tag': {
-    find: 'artTag',
-    link: 'linkArtTag',
-  },
-
-  'track': {
-    find: 'track',
-    link: 'linkTrackDynamically',
-  },
-};
-
 const commonMarkedOptions = {
   headerIds: false,
   mangle: false,
diff --git a/src/util/replacer.js b/src/util/replacer.js
index d9fd8923..c1d13c7c 100644
--- a/src/util/replacer.js
+++ b/src/util/replacer.js
@@ -8,6 +8,142 @@
 import * as html from '#html';
 import {escapeRegex, typeAppearance} from '#sugar';
 
+export const replacerSpec = {
+  'album': {
+    find: 'album',
+    link: 'linkAlbum',
+  },
+
+  'album-commentary': {
+    find: 'album',
+    link: 'linkAlbumCommentary',
+  },
+
+  'album-gallery': {
+    find: 'album',
+    link: 'linkAlbumGallery',
+  },
+
+  'artist': {
+    find: 'artist',
+    link: 'linkArtist',
+  },
+
+  'artist-gallery': {
+    find: 'artist',
+    link: 'linkArtistGallery',
+  },
+
+  'commentary-index': {
+    find: null,
+    link: 'linkCommentaryIndex',
+  },
+
+  'date': {
+    find: null,
+    value: (ref) => new Date(ref),
+    html: (date, {html, language}) =>
+      html.tag('time',
+        {datetime: date.toUTCString()},
+        language.formatDate(date)),
+  },
+
+  'flash-index': {
+    find: null,
+    link: 'linkFlashIndex',
+  },
+
+  'flash': {
+    find: 'flash',
+    link: 'linkFlash',
+    transformName(name, node, input) {
+      const nextCharacter = input[node.iEnd];
+      const lastCharacter = name[name.length - 1];
+      if (![' ', '\n', '<'].includes(nextCharacter) && lastCharacter === '.') {
+        return name.slice(0, -1);
+      } else {
+        return name;
+      }
+    },
+  },
+
+  'flash-act': {
+    find: 'flashAct',
+    link: 'linkFlashAct',
+  },
+
+  'group': {
+    find: 'group',
+    link: 'linkGroup',
+  },
+
+  'group-gallery': {
+    find: 'group',
+    link: 'linkGroupGallery',
+  },
+
+  'home': {
+    find: null,
+    link: 'linkWikiHome',
+  },
+
+  'listing-index': {
+    find: null,
+    link: 'linkListingIndex',
+  },
+
+  'listing': {
+    find: 'listing',
+    link: 'linkListing',
+  },
+
+  'media': {
+    find: null,
+    link: 'linkPathFromMedia',
+  },
+
+  'news-index': {
+    find: null,
+    link: 'linkNewsIndex',
+  },
+
+  'news-entry': {
+    find: 'newsEntry',
+    link: 'linkNewsEntry',
+  },
+
+  'root': {
+    find: null,
+    link: 'linkPathFromRoot',
+  },
+
+  'site': {
+    find: null,
+    link: 'linkPathFromSite',
+  },
+
+  'static': {
+    find: 'staticPage',
+    link: 'linkStaticPage',
+  },
+
+  'string': {
+    find: null,
+    value: (ref) => ref,
+    html: (ref, {language, args}) => language.$(ref, args),
+  },
+
+  'tag': {
+    find: 'artTag',
+    link: 'linkArtTag',
+  },
+
+  'track': {
+    find: 'track',
+    link: 'linkTrackDynamically',
+  },
+};
+
 // Syntax literals.
 const tagBeginning = '[[';
 const tagEnding = ']]';