From cd3a59d5024984a2d3be5164f6b2ce9ee05e9f62 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 27 Feb 2022 12:13:53 -0400 Subject: generalized reference errors --- src/util/replacer.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/util/replacer.js') diff --git a/src/util/replacer.js b/src/util/replacer.js index 6c524778..0066d218 100644 --- a/src/util/replacer.js +++ b/src/util/replacer.js @@ -1,8 +1,7 @@ -import find from './find.js'; import {logError, logWarn} from './cli.js'; import {escapeRegex} from './sugar.js'; -export function validateReplacerSpec(replacerSpec, link) { +export function validateReplacerSpec(replacerSpec, {find, link}) { let success = true; for (const [key, {link: linkKey, find: findKey, value, html}] of Object.entries(replacerSpec)) { @@ -320,7 +319,7 @@ export function parseInput(input) { } function evaluateTag(node, opts) { - const { input, link, replacerSpec, strings, to, wikiData } = opts; + const { find, input, link, replacerSpec, strings, to, wikiData } = opts; const source = input.slice(node.i, node.iEnd); @@ -348,7 +347,7 @@ function evaluateTag(node, opts) { valueFn ? valueFn(replacerValue) : findKey ? find[findKey]((replacerKeyImplied ? replacerValue - : replacerKey + `:` + replacerValue), {wikiData}) : + : replacerKey + `:` + replacerValue)) : { directory: replacerValue, name: null @@ -417,13 +416,14 @@ function transformNodes(nodes, opts) { return nodes.map(node => transformNode(node, opts)).join(''); } -export function transformInline(input, {replacerSpec, link, strings, to, wikiData}) { +export function transformInline(input, {replacerSpec, find, link, strings, to, wikiData}) { if (!replacerSpec) throw new Error('Expected replacerSpec'); + if (!find) throw new Error('Expected find'); if (!link) throw new Error('Expected link'); if (!strings) throw new Error('Expected strings'); if (!to) throw new Error('Expected to'); if (!wikiData) throw new Error('Expected wikiData'); const nodes = parseInput(input); - return transformNodes(nodes, {input, link, replacerSpec, strings, to, wikiData}); + return transformNodes(nodes, {input, find, link, replacerSpec, strings, to, wikiData}); } -- cgit 1.3.0-6-gf8a5