-- box-filter.lua -- Converts fenced divs like: -- ::: {.defbox title="Def. 1.1 -- Something"} -- content (normal Markdown: **bold**, lists, code blocks, math...) -- ::: -- into raw LaTeX tcolorbox environments (defbox/theobox/exbox), while the -- content itself stays as ordinary Markdown blocks that pandoc converts -- normally (bold -> \textbf, code fences -> lstlisting, etc.). local boxnames = { defbox = true, theobox = true, exbox = true } function Div(el) for name, _ in pairs(boxnames) do if el.classes:includes(name) then local title = el.attributes["title"] or "" local open = pandoc.RawBlock("latex", "\\begin{" .. name .. "}[" .. title .. "]") local close = pandoc.RawBlock("latex", "\\end{" .. name .. "}") local blocks = { open } for _, b in ipairs(el.content) do table.insert(blocks, b) end table.insert(blocks, close) return blocks end end return nil end