From f8a7a9ab00efe774f28f8f3211aef90a9abfc6be Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Fri, 2 Oct 2026 10:29:20 +0200 Subject: better support h1 headings in markdown files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit we don't want to include them in the generated toc Signed-off-by: Robert Günzler --- src/preproc.lua | 62 ++++++++++++++++++++++++++++++++------------------------- 1 file changed, 35 insertions(+), 27 deletions(-) (limited to 'src/preproc.lua') diff --git a/src/preproc.lua b/src/preproc.lua index 76f0678..4d58053 100644 --- a/src/preproc.lua +++ b/src/preproc.lua @@ -9,50 +9,58 @@ return { return link end, Pandoc = function(doc) - local front = {} + local front = pandoc.List() + local doc_filename = pandoc.path.filename(PANDOC_STATE.input_files[1]) -- add a comment - table.insert( - front, - pandoc.RawBlock( - "html5", - "" - ) - ) + front:extend({ + 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", "")) + front:extend({ + pandoc.RawBlock("html5", ''), + doc.meta.date, + pandoc.RawBlock("html5", ""), + }) end -- prepend front stuffs - for i = #front, 1, -1 do - table.insert(doc.blocks, 1, front[i]) - end + front:extend(doc.blocks) + doc.blocks = front -- return finished ast return doc -- cgit 1.4.1