From 23d862844c4cce0100bedd20a8b521ab9f8f822d Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Wed, 16 Oct 2024 15:24:41 +0200 Subject: use pandoc filter to generate date & toc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Robert Günzler --- front.lua | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 front.lua (limited to 'front.lua') diff --git a/front.lua b/front.lua new file mode 100644 index 0000000..a6046b1 --- /dev/null +++ b/front.lua @@ -0,0 +1,42 @@ +---@diagnostic disable: undefined-global +-- see https://pandoc.org/lua-filters.html +return { + Pandoc = function(doc) + local front = {} + + local toc = pandoc.structure.table_of_contents(doc) + if doc.meta.toc and toc then + table.insert(front, pandoc.RawBlock("html5", '
')) + table.insert(front, pandoc.RawBlock("html5", '")) + table.insert(front, pandoc.RawBlock("html5", "
")) + end + + -- insert date blocks + if doc.meta.date then + table.insert(front, pandoc.RawBlock("html5", '')) + table.insert(front, doc.meta.date) + table.insert(front, pandoc.RawBlock("html5", "")) + end + + -- prepend front stuffs + for i = #front, 1, -1 do + table.insert(doc.blocks, 1, front[i]) + end + + -- return finished ast + return doc + end, +} -- cgit 1.4.1