Skip to content

Is there are better way to do --embed-resources feature for --to jats? #9798

Answered by tarleb
castedo asked this question in Q&A
Discussion options

You must be logged in to vote

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.

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

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by castedo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants