function dump(o) if type(o) == 'table' then local s = '{ ' for k, v in pairs(o) do if type(k) ~= 'number' then k = '"' .. k .. '"' end s = s .. '[' .. k .. '] = ' .. dump(v) .. ',' end return s .. '} ' else return tostring(o) end end function string.split(str, sep) sep = sep or '%s' local parts = pandoc.List() for field, s in str:gmatch("([^" .. sep .. "]*)(" .. sep .. "?)") do parts:insert(field) if s == "" then return parts end end end function pandoc.List:flatten() local result = pandoc.List() for i = 1, #self do result:extend(self[i]) end return result end function pandoc.List:flatMap(fn) local mapped = self:map(fn) local result = pandoc.List() for i = 1, #mapped do result:extend(mapped[i]) end return result end function pandoc.List:take(n) if n >= #self then return self end local result = pandoc.List() for i = 1, n do result:insert(self[i]) end return result end return { dump = dump }