ah, yes, good, that way we're sure we iterate on a fixed list, a snapshot before the changes.

so with this, and a check on the mime type, we get something like :


-----
local outputfile = PANDOC_STATE.output_file:gsub("%.md", "")

local function prefixName(s)
 
return s:gsub("([^/]*)$", outputfile .. "_%1")
end

function Image(img)
  img
.src = prefixName(img.src)
 
return img
end

function Pandoc(doc)
 
for _,f in ipairs(pandoc.mediabag.list()) do
   
local fp = f.path
   
local mt, contents = pandoc.mediabag.lookup(fp)
   
if mt:match("^[^/]*") == "image" then
     
local fpnew = prefixName(fp)
      pandoc
.mediabag.insert(fpnew, mt, contents)
      pandoc
.mediabag.delete(fp)
   
end
 
end
end
-----


--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/6d556139-e107-4ad4-a99d-62b07bd9ad3d%40googlegroups.com.