Skip to content

Commit

Permalink
DEV: handle TODO item in <p> tag
Browse files Browse the repository at this point in the history
  • Loading branch information
altairwei committed Apr 21, 2024
1 parent 169022e commit 4a57a18
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
1 change: 0 additions & 1 deletion share/pandoc/custom/zipfile.lua
Expand Up @@ -20,7 +20,6 @@ function ByteStringReader(input)
local indexfile = indexent:contents()
local doc = pandoc.read(indexfile, "html", PANDOC_READER_OPTIONS)
doc = doc:walk(html.WizHtmlFilter)
--logging.temp(doc)
return doc
end

Expand Down
38 changes: 20 additions & 18 deletions share/pandoc/modules/wizhtml.lua
Expand Up @@ -50,25 +50,21 @@ function module.handle_wiz_nested_list(elem)
end
-- Convert WizNote TODO item
function module.handle_wiz_checkbox_item(elem)
if elem.classes[1] == "wiz-todo-layer" then
local todo = elem.content[1]
todo = todo:walk {
Span = function(span)
return span.content
end,
Image = function(img)
if img.classes[1] == "wiz-todo-checkbox" then
if img.attributes["wiz-check"] == "unchecked" then
return {pandoc.Str(""), pandoc.Space()}
else
return {pandoc.Str(""), pandoc.Space()}
end
function module.handle_wiz_checkbox_item(todo)
return todo:walk {
Span = function(span)
return span.content
end,
Image = function(img)
if img.classes[1] == "wiz-todo-checkbox" then
if img.attributes["wiz-check"] == "unchecked" then
return {pandoc.Str(""), pandoc.Space()}
else
return {pandoc.Str(""), pandoc.Space()}
end
end
}
return todo
end
end
}
end
-- Collect consecutive TODO items and convert them to a BulletList
Expand All @@ -90,7 +86,13 @@ function module.collect_wiz_todo_items(blocks)
if elem.t == "Div" and elem.classes[1] == "wiz-todo-layer" then
if not inTodoList then inTodoList = true end
todolist[#todolist+1] = pandoc.Blocks(module.handle_wiz_checkbox_item(elem))
todolist[#todolist+1] = pandoc.Blocks(
module.handle_wiz_checkbox_item(elem.content[1]))
elseif elem.t == "Para" and #elem.content > 1 and elem.content[1].t == "Span"
and elem.content[1].classes[1] == "wiz-todo-main" then
if not inTodoList then inTodoList = true end
todolist[#todolist+1] = pandoc.Blocks(
module.handle_wiz_checkbox_item(pandoc.Plain(elem.content)))
elseif elem.t == "BlockQuote" and #todolist > 0 then
todolist[#todolist] = util.concatArray(todolist[#todolist], elem.content)
else
Expand Down

0 comments on commit 4a57a18

Please sign in to comment.