Skip to content

Commit 3c12a2b

Browse files
committed
1 parent 567c5be commit 3c12a2b

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

inst/sec-depth.lua

+19-9
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,26 @@ function Pandoc (doc)
33
-- `true` ensures that headings are numbered.
44
doc.blocks = pandoc.utils.make_sections(true, nil, doc.blocks)
55

6-
-- Shift the heading levels by 1
7-
doc.blocks = doc.blocks:walk {
8-
Header = function (h)
9-
if h.level > 2 then
10-
h.classes:insert 'unnumbered'
11-
end
12-
h.level = h.level + 1
13-
return h
6+
-- Check if doc.blocks is not nil
7+
if doc.blocks then
8+
-- Check if walk method exists
9+
if doc.blocks.walk then
10+
-- Shift the heading levels by 1
11+
doc.blocks = doc.blocks:walk {
12+
Header = function (h)
13+
if h.level > 2 then
14+
h.classes:insert 'unnumbered'
15+
end
16+
h.level = h.level + 1
17+
return h
18+
end
19+
}
20+
else
21+
print("Error: walk method does not exist")
1422
end
15-
}
23+
else
24+
print("Error: doc.blocks is nil")
25+
end
1626

1727
-- Return the modified document
1828
return doc

0 commit comments

Comments
 (0)