function wide(el)
local els = pandoc.List()
els:insert(pandoc.RawBlock("html", ""))
els:insert(el)
els:insert(pandoc.RawBlock("html", "
"))
return els
end
function alert(el)
el.classes = pandoc.List()
el.classes:insert("o-alert")
el.classes:insert("o-alert--primary")
el.classes:insert("s-alerts__alert")
return wide(el)
end
function figure(el)
local images = pandoc.List()
pandoc.walk_block(el, { Image = function(iel) images:insert(iel) end })
el = pandoc.RawBlock("html",
"")
return wide(el)
end
function Div(el)
if el.classes:includes("alert") then
el = alert(el)
elseif el.classes:includes("figure") then
el = figure(el)
end
return el
end
function CodeBlock(el)
if el.classes[1] == "plain" then
el = pandoc.Div({ el }, { class = 's-code' })
elseif el.classes[1] then
local formatted = pandoc.pipe('pygmentize', {
'-l', el.classes[1], '-f', 'html', '-O', 'cssclass=s-code s-code--highlight',
}, el.text)
if formatted then el = pandoc.RawBlock('html', formatted) end
end
return wide(el)
end
function Header(el)
if el.level <= 3 then
local newchildren = pandoc.List()
newchildren:insert(pandoc.Span(el.content, { class = 's-headings__primary' }))
el.content = newchildren
end
return el
end
function Table(el)
return wide(el)
end
function Str(el)
local icon = el.text:match('^:(.*):$')
if icon then
return pandoc.RawInline('html',
'')
end
return el
end