summaryrefslogtreecommitdiffstats
path: root/filters/code.lua
blob: aca3ce840f4988bd7ac2254aeee470cf8efc4154 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
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 el
end