Skip to content

Commit

Permalink
fix(packages): Converters package no longer worked after 0.13.0
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Omikhleia authored and Didier Willis committed May 5, 2023
1 parent 7e7026b commit 433795c
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions packages/converters/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand Down

0 comments on commit 433795c

Please sign in to comment.