Is it possible to modify the resource path from lua? #10670
-
I need to dynamically load markdown files referencing resources relatively. E.g. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Currently it's not possible. I have a WIP branche in which I tried to create a solution for that, but that needs more work. |
Beta Was this translation helpful? Give feedback.
-
@CodeSandwich -- as a workaround, you can use a filter to change all image paths before rendering so that they are relative to the working directory rather than the document in which they appear: -- read Markdown file
local mdpath = 'subdir/doc.md'
local doc = pandoc.read(select(2, pandoc.mediabag.fetch(mdpath)))
-- run filter to make image paths relative to working dir
doc = doc:walk {
---@type fun(img: Image): Image
Image = function(img)
img.src = pandoc.path.join { pandoc.path.directory(mdpath), img.src }
return img
end,
}
-- render doc
print(pandoc.write(doc, 'html')) You can find a full example here: https://github.com/rnwst/pandoc-discussions/tree/master/10670 |
Beta Was this translation helpful? Give feedback.
Currently it's not possible. I have a WIP branche in which I tried to create a solution for that, but that needs more work.