diff options
author | Ekaitz Zarraga <ekaitz@elenq.tech> | 2020-05-27 16:12:49 +0200 |
---|---|---|
committer | Ekaitz Zarraga <ekaitz@elenq.tech> | 2020-05-27 16:12:49 +0200 |
commit | de8d5726358d36a9bf7eecef2fd74b20fa1b393c (patch) | |
tree | 003f6d42042597bf9994b82ebd1caea57f438085 /filters | |
parent | 0ac99d9a4349ee76f44ba8180abb72eb79f98e69 (diff) |
Filter for section numbering for HTML
Diffstat (limited to 'filters')
-rw-r--r-- | filters/section-numbers.lua | 18 |
1 files changed, 18 insertions, 0 deletions
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 |