From de8d5726358d36a9bf7eecef2fd74b20fa1b393c Mon Sep 17 00:00:00 2001 From: Ekaitz Zarraga Date: Wed, 27 May 2020 16:12:49 +0200 Subject: Filter for section numbering for HTML --- filters/section-numbers.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 filters/section-numbers.lua diff --git a/filters/section-numbers.lua b/filters/section-numbers.lua new file mode 100644 index 0000000..04c168d --- /dev/null +++ b/filters/section-numbers.lua @@ -0,0 +1,18 @@ +sections_count = 0 + +if FORMAT:match 'html' then + function Header(el) + + if not (el.level == 2) then + return el + end + local numb = pandoc.Str(tostring(sections_count + 1)..".") + sections_count = sections_count + 1 + local new_cont = {numb, pandoc.Space()} + for i,v in ipairs(el.content) do + new_cont[i+2]=el.content[i] + end + el.content = new_cont + return el + end +end -- cgit v1.2.3