-
I am embedding base 64 encoded images inside JATS XML by doing the following shell pipe:
This results is XML like this:
Is there better way to achieve this? Perhaps by copying and reusing an existing lua script? The |
Beta Was this translation helpful? Give feedback.
Answered by
tarleb
May 24, 2024
Replies: 1 comment
-
Here'd be my approach. My quick local base64 = {}
base64.encode = function (data)
return pandoc.pipe('base64', {'--wrap=0'}, data)
end
function Image (img)
local mime, contents = pandoc.mediabag.fetch(img.src)
img.src = 'data:' .. mime .. ';base64,' .. base64.encode(contents)
return img
end |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
castedo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here'd be my approach. My quick
base64.encode
hack should probably be replaced with a proper Lua encoder, of which there are quite a few out there.