Also there is no guarantee that the file extension on the Markdown file is `.md`. Some people use `.mkd` or `.txt` and it may even be an `.rst` file so it may be better to use the old and tried generic pattern `%.[^%.]*$`, which matches any extension, to match the file extension. Den ons 18 mars 2020 23:37EBkysko skrev: > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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 > > . > -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CADAJKhBfF-_hkBLJ0M5AnAL4aWJMs03JDbNj3wjjD7P6_-6fcA%40mail.gmail.com.