Skip to content

Commit

Permalink
improve fix for cysouw#15
Browse files Browse the repository at this point in the history
use List.insert to add "restart" class to header
added back check that "restart" class had been added
  • Loading branch information
somelinguist authored Dec 13, 2023
1 parent d721c80 commit 4e4da4e
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions pandoc-ling.lua
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ function addDivToHeader (head)
and head.level == 1
and head.classes[1] ~= "unnumbered"
then
head.classes:extend({"restart"})
head.classes:insert(1, "restart")
return pandoc.Div(head)
end
end
Expand All @@ -229,16 +229,10 @@ function processDiv (div)

-- keep track of chapters (header == 1)
-- included in this loop by trick "addDivToHeader"
if div.content[1].tag == "Header" then
if div.content[1].tag == "Header" and div.content[1].classes[1] == "restart" then
chapter = chapter + 1
counterInChapter = 0
classes = {}
for _,cls in ipairs(div.content[1].classes) do
if cls ~= "restart" then
table.insert(classes, cls)
end
end
div.content[1].classes = classes
div.content[1].classes:remove(1)
-- remove div
return div.content
end
Expand Down

0 comments on commit 4e4da4e

Please sign in to comment.