From 24460c250816e9b1dc06c5348f4c470bc98f7153 Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Mon, 28 Oct 2024 12:15:35 +0100 Subject: renmae front.lua to preproc.lua MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Robert Günzler --- front.lua | 42 ------------------------------------------ makefile | 5 +++-- preproc.lua | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 44 deletions(-) delete mode 100644 front.lua create mode 100644 preproc.lua diff --git a/front.lua b/front.lua deleted file mode 100644 index a6046b1..0000000 --- a/front.lua +++ /dev/null @@ -1,42 +0,0 @@ ----@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, -} diff --git a/makefile b/makefile index 6d448b0..838a275 100644 --- a/makefile +++ b/makefile @@ -2,15 +2,16 @@ all: run # content PANDOC ?= pandoc +PANDOC_PREPROC ?= preproc.lua htm_SRC := $(shell find src/inc/ -name '*.htm' -print) md_SRC := $(shell find src/inc/ -name '*.md' -print) SRC := $(htm_SRC) $(md_SRC:%.md=%.htm) DST := site # see https://pandoc.org/MANUAL.html#pandocs-markdown -%.htm: %.md front.lua +%.htm: %.md $(PANDOC_PREPROC) @ echo "" >$@ - $(PANDOC) -fmarkdown -thtml5 --lua-filter=front.lua $< >>$@ + $(PANDOC) -fmarkdown -thtml5 --lua-filter=$(PANDOC_PREPROC) $< >>$@ # generator ZIG ?= zig diff --git a/preproc.lua b/preproc.lua new file mode 100644 index 0000000..6bfa8c5 --- /dev/null +++ b/preproc.lua @@ -0,0 +1,40 @@ +---@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", '")) + 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