From a72850024a910d5f83e76d26137403666b3c7902 Mon Sep 17 00:00:00 2001 From: Context Git Mirror Bot Date: Tue, 13 Jan 2015 11:15:05 +0100 Subject: 2015-01-13 11:02:00 --- scripts/context/lua/mtx-epub.lua | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'scripts') diff --git a/scripts/context/lua/mtx-epub.lua b/scripts/context/lua/mtx-epub.lua index 7b3ba2ebd..a383cfd90 100644 --- a/scripts/context/lua/mtx-epub.lua +++ b/scripts/context/lua/mtx-epub.lua @@ -282,21 +282,24 @@ local function relocateimages(imagedata,oldname,newname,subpath,rename) report("relocating images") local n = 0 local done = gsub(data,[[(id=")(.-)(".-background%-image *: *url%()(.-)(%))]], function(s1,id,s2,name,s3) - local newname = imagedata[id].newname - if newname then - if subpath then - name = joinfile(subpath,basename(newname)) - else - name = basename(newname) + local data = imagedata[id] + if data then + local newname = data[id].newname + if newname then + if subpath then + name = joinfile(subpath,basename(newname)) + else + name = basename(newname) + end + -- name = url.addscheme(name) end - -- name = url.addscheme(name) - end - if newname then - n = n + 1 - if rename then - name = joinfile(subpath,addsuffix(id,suffix(name))) + if newname then + n = n + 1 + if rename then + name = joinfile(subpath,addsuffix(id,suffix(name))) + end + return s1 .. id .. s2 .. name .. s3 end - return s1 .. id .. s2 .. name .. s3 end end) report("%s images relocated in %a",n,newname) -- cgit v1.2.3