Skip to content

Commit

Permalink
Improve section depth lua filter to maintain correct web numbering style
Browse files Browse the repository at this point in the history
Resolves #88
  • Loading branch information
mitchelloharawild committed Oct 4, 2023
1 parent 8da11ba commit 6d40421
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions inst/sec-depth.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
function Pandoc (doc)
-- Create and number sections. Setting the first parameter to
-- `true` ensures that headings are numbered.
doc.blocks = pandoc.utils.make_sections(true, nil, doc.blocks)

function Header (h)
if h.level > 2 then
h.classes:insert 'unnumbered'
end
return h
-- Shift the heading levels by 1
doc.blocks = doc.blocks:walk {
Header = function (h)
if h.level > 2 then
h.classes:insert 'unnumbered'
end
h.level = h.level + 1
return h
end
}

-- Return the modified document
return doc
end

0 comments on commit 6d40421

Please sign in to comment.