Skip to content

Commit

Permalink
Merge pull request #123 from pachadotdev/main
Browse files Browse the repository at this point in the history
fix #122
  • Loading branch information
dicook authored Sep 17, 2024
2 parents 567c5be + f7387e9 commit c0f4fe1
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions inst/sec-depth.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,26 @@ function Pandoc (doc)
-- `true` ensures that headings are numbered.
doc.blocks = pandoc.utils.make_sections(true, nil, doc.blocks)

-- 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
-- Check if doc.blocks is not nil
if doc.blocks then
-- Check if walk method exists
if doc.blocks.walk then
-- 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
}
else
print("Error: walk method does not exist")
end
}
else
print("Error: doc.blocks is nil")
end

-- Return the modified document
return doc
Expand Down

0 comments on commit c0f4fe1

Please sign in to comment.