From 435af33e7e33ff664f6b01d2e02486de1346f20a Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 8 Sep 2025 19:27:06 -0300 Subject: content: transformContent: substitute apply() --- src/content/dependencies/transformContent.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/content/dependencies/transformContent.js') 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) { -- cgit 1.3.0-6-gf8a5