From 5f748385efffecf2e30ed5c70e2394cfac39a4b5 Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Thu, 24 Sep 2026 18:00:17 +0200 Subject: embed preproc.lua script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Robert Günzler --- src/preproc.lua | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/preproc.lua (limited to 'src/preproc.lua') diff --git a/src/preproc.lua b/src/preproc.lua new file mode 100644 index 0000000..76f0678 --- /dev/null +++ b/src/preproc.lua @@ -0,0 +1,60 @@ +---@diagnostic disable: undefined-global +-- see https://pandoc.org/lua-filters.html +return { + Link = function(link) + -- set target="_blank" for outgoing links (open them in new tab) + if string.match(link.target, "gzr.im") == nil then + table.insert(link.attributes, { "target", "_blank" }) + end + return link + end, + Pandoc = function(doc) + local front = {} + + -- add a comment + table.insert( + front, + pandoc.RawBlock( + "html5", + "" + ) + ) + + local toc = pandoc.structure.table_of_contents(doc) + if doc.meta.toc and toc then + 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