Skip to content

Commit

Permalink
Automatically create question tag if one isn't yet opened
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchelloharawild committed Dec 13, 2023
1 parent 8903f28 commit 470daea
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions inst/header.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 470daea

Please sign in to comment.