diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2025-09-08 19:27:06 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2025-09-08 19:27:06 -0300 |
commit | 435af33e7e33ff664f6b01d2e02486de1346f20a (patch) | |
tree | 44ad74caf231c670c27e1e432bf069aa6f9e0cf9 /src/content/dependencies/transformContent.js | |
parent | 27b4de9be0f23e25bdb6eb81e3e48c50cb0d4163 (diff) |
content: transformContent: substitute apply()
Diffstat (limited to 'src/content/dependencies/transformContent.js')
-rw-r--r-- | src/content/dependencies/transformContent.js | 17 |
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) { |