From 433795c3979688469a098a9966a595a4b0d34818 Mon Sep 17 00:00:00 2001 From: Omikhleia Date: Fri, 5 May 2023 14:19:03 +0200 Subject: [PATCH] fix(packages): Converters package no longer worked after 0.13.0 Due an inadvertently inverted check. Also if wasn't resolving the source file name so could not work with relative paths that would have been acceptable for a resource not needing conversion. --- packages/converters/init.lua | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/packages/converters/init.lua b/packages/converters/init.lua index ecc4b68aa..79d341e92 100644 --- a/packages/converters/init.lua +++ b/packages/converters/init.lua @@ -59,11 +59,12 @@ function package.register (_, sourceExt, targetExt, command) end function package.checkConverters (_, source) + local resolvedSrc = SILE.resolveFile(source) or SU.error("Couldn't find file " .. source) for _, converter in ipairs(SILE.scratch.converters) do local extLen = string.len(converter.sourceExt) - if ((string.len(source) > extLen) and - (string.sub(source, -extLen) == converter.sourceExt)) then - return applyConverter(source, converter) + if ((string.len(resolvedSrc) > extLen) and + (string.sub(resolvedSrc, -extLen) == converter.sourceExt)) then + return applyConverter(resolvedSrc, converter) end end return source -- No conversion needed. @@ -75,17 +76,23 @@ function package:_init () SILE.scratch.converters = {} end extendCommand("include", function (options, content, original) - local result = self:checkConverters(options.src) - if not result then + local source = SU.required(options, "src", "include (converters)") + local result = self:checkConverters(source) + if result then options["src"] = result original(options, content) + else + SU.error("Conversion failure for include '" .. source ..'"') end end) extendCommand("img", function (options, content, original) - local result = self:checkConverters(options.src) - if not result then + local source = SU.required(options, "src", "img (converters)") + local result = self:checkConverters(source) + if result then options["src"] = result original(options, content) + else + SU.error("Conversion failure for image '" .. source ..'"') end end) self:deprecatedExport("register", self.register)