Skip to content
Discussion options

You must be logged in to vote

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.

-- 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)
end

So a plain line on its own:

Keep this.

QUIT

Drop everything from here.

run through pandoc doc.md --lua-filte…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jidanni
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