lua filter to act like we've hit EOF possible? #11651
|
From https://pandoc.org/filters.html#a-simple-example How might I do that with a lua filter? Reading https://pandoc.org/lua-filters.html
But that still requires me to wrap all the stuff I want to exclude into Is it possible to have a lua filter send a message to pandoc's Note I am just trying to simulate hitting EOF (End Of input File), not Or could I use
thus my Div need only be a couple lines long, no need to enclose the |
Replies: 1 comment
|
Yes. Use a whole-document -- truncate.lua: stop at the first top-level block that is exactly "QUIT"
function Pandoc(doc)
local kept = {}
for _, block in ipairs(doc.blocks) do
if pandoc.utils.stringify(block) == "QUIT" then
break -- drop the marker and everything after it
end
kept[#kept + 1] = block
end
return pandoc.Pandoc(kept, doc.meta)
endSo a plain line on its own: run through On the "other filters waiting in line" question: pandoc runs A couple of notes:
Tested on pandoc 3.9. |
Yes. Use a whole-document
Pandoc(doc)filter instead of matching individual elements. It receives the entire block list, so you can walk it, stop at your marker, and drop everything from there on. No Div wrapping needed.So a plain line on its own:
run through
pandoc doc.md --lua-filte…