pandoc-cl/timesheet.lua

44 lines
717 B
Lua
Raw Permalink Normal View History

2020-12-07 16:33:52 +00:00
require 'io'
local timesheet_export = nil
local timesheet_content = ""
local function Meta(meta)
timesheet_export = pandoc.utils.stringify(meta['timesheet'])
return nil
end
local function save_timesheet(content)
timesheet_content = timesheet_content .. content
end
local function CodeBlock(elem)
for k,v in ipairs(elem.classes) do
if v == 'timesheet' then
save_timesheet(elem.text)
end
end
-- do not modify elem
return nil
end
local function save()
file = io.open(timesheet_export, 'w+')
file:write(timesheet_content)
file:close()
end
local function Pandoc(pandoc)
save()
return nil
end
return {
{ Meta = Meta },
{ CodeBlock = CodeBlock },
{ Pandoc = Pandoc }
}