summaryrefslogtreecommitdiffstats
path: root/filters/code.lua
blob: 2d6e5a5dfabdcd814cf92d2d0382c7fefdea1e50 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
local common = require 'filters.lib.common'

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 common.wide(el)
end