Last active
September 30, 2024 21:46
-
-
Save bakaburg1/9df96ad28f0a83c6594e582c56ace304 to your computer and use it in GitHub Desktop.
A filter to store image captions into the Meta fields
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function RawBlock (raw) | |
local caption = raw.text:match("\\caption%{[^%}]+%}") | |
if caption then | |
captions:insert(caption) | |
end | |
end | |
function Pandoc (doc) | |
-- append collected captions at the end | |
doc.meta.figures = captions -- This works but latex is escaped by \textbackslash | |
-- doc.meta.figures = {pandoc.RawBlock("latex", captions)} -- This produces error | |
return doc | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment