« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/transformContent.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/dependencies/transformContent.js')
-rw-r--r--src/content/dependencies/transformContent.js17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/content/dependencies/transformContent.js b/src/content/dependencies/transformContent.js
index 83c85d05..4646a6eb 100644
--- a/src/content/dependencies/transformContent.js
+++ b/src/content/dependencies/transformContent.js
@@ -307,6 +307,8 @@ export default {
             }),
 
             substitute: v.isHTML,
+
+            apply: v.optional(v.isFunction),
           })),
     },
   },
@@ -363,7 +365,20 @@ export default {
         const substitution = pickSubstitution(node);
 
         if (substitution) {
-          return {type: 'substitution', data: substitution.substitute};
+          const source =
+            substitution.substitute;
+
+          let substitute = source;
+
+          if (substitution.apply) {
+            const result = substitution.apply(source, node);
+
+            if (result !== undefined) {
+              substitute = result;
+            }
+          }
+
+          return {type: 'substitution', data: substitute};
         }
 
         switch (node.type) {