Skip to content

Commit

Permalink
Detect cloze environments anywhere in CodeBlocks
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchelloharawild committed Dec 13, 2023
1 parent cab5617 commit 3af61e8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion inst/header.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ local moodle_category = [[
</question>
]]

local cloze_pattern = "{%d+:"

function process_header (elem)
if (elem.classes[1] == "header" or elem.level > 2) then return elem end
elem.classes = {'question'}
Expand Down Expand Up @@ -58,7 +60,10 @@ function Pandoc(doc)
has_cloze = false
el.content:walk {
RawInline = function(el)
if(el.text:find("^{%d+:") ~= nil) then has_cloze = true end
if(el.text:find(cloze_pattern) ~= nil) then has_cloze = true end
end,
CodeBlock = function(el)
if(el.text:find(cloze_pattern) ~= nil) then has_cloze = true end
end
}
if has_cloze then
Expand Down

0 comments on commit 3af61e8

Please sign in to comment.