From 6d868d605c43e38373f1b88f99901c3e43b69cdb Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Tue, 22 Sep 2026 17:58:42 +0200 Subject: format preproc script and add comment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Robert Günzler --- preproc.lua | 89 ++++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 50 insertions(+), 39 deletions(-) (limited to 'preproc.lua') diff --git a/preproc.lua b/preproc.lua index 7be9a48..e9aa366 100644 --- a/preproc.lua +++ b/preproc.lua @@ -1,47 +1,58 @@ ---@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 = {} + 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 = {} - local toc = pandoc.structure.table_of_contents(doc) - if doc.meta.toc and toc then - table.insert(front, pandoc.RawBlock("html5", '")) - end + -- add a comment + table.insert( + front, + pandoc.RawBlock( + "html5", + "" + ) + ) - -- 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 + local toc = pandoc.structure.table_of_contents(doc) + if doc.meta.toc and toc then + table.insert(front, pandoc.RawBlock("html5", '")) + end - -- prepend front stuffs - for i = #front, 1, -1 do - table.insert(doc.blocks, 1, front[i]) - 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 - -- return finished ast - return doc - 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