« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/content/dependencies/transformContent.js24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/content/dependencies/transformContent.js b/src/content/dependencies/transformContent.js
index 48e20f94..f61865bb 100644
--- a/src/content/dependencies/transformContent.js
+++ b/src/content/dependencies/transformContent.js
@@ -258,6 +258,20 @@ export default {
       data.nodes.map((node, index) => {
         const nextNode = data.nodes[index + 1];
 
+        const absorbFollowingPunctuation = template => {
+          if (nextNode?.type !== 'text') {
+            return;
+          }
+
+          const text = nextNode.data;
+          const match = text.match(/^[.,;:?!…]+/);
+          const suffix = match?.[0];
+          if (suffix) {
+            template.setSlot('suffixNormalContent', suffix);
+            offsetTextNode = suffix.length;
+          }
+        };
+
         switch (node.type) {
           case 'text': {
             const text = node.data.slice(offsetTextNode);
@@ -458,14 +472,8 @@ export default {
               fromContent: true,
             });
 
-            if (slots.absorbPunctuationFollowingExternalLinks && nextNode?.type === 'text') {
-              const text = nextNode.data;
-              const match = text.match(/^[.,;:?!…]+/);
-              const suffix = match?.[0];
-              if (suffix) {
-                externalLink.setSlot('suffixNormalContent', suffix);
-                offsetTextNode = suffix.length;
-              }
+            if (slots.absorbPunctuationFollowingExternalLinks) {
+              absorbFollowingPunctuation(externalLink);
             }
 
             if (slots.indicateExternalLinks) {