diff --git a/inst/header.lua b/inst/header.lua index a86829d..d5fb6fe 100644 --- a/inst/header.lua +++ b/inst/header.lua @@ -25,17 +25,17 @@ end function Pandoc(doc) local hblocks = {} local category_idx = 0 - local in_category = false + local in_question = false for i,el in pairs(doc.blocks) do if (el.t ~= "Header" or el.level > 2 or el.classes[1] == "header") then - if (not in_category) then + -- If a question div hasn't yet been opened, create one. + if (not in_question) then + in_question = true category_idx = category_idx + 1 - table.insert(hblocks, el) - else - hblocks[category_idx].content:insert(el) + table.insert(hblocks, process_header(pandoc.Header(2, 'Unnamed question', pandoc.Attr()))) end + hblocks[category_idx].content:insert(el) elseif (el.t == "Header") then - in_category = true category_idx = category_idx + 1 table.insert(hblocks, process_header(el)) end