summaryrefslogtreecommitdiffstats
path: root/filters/macros.lua
blob: ca0b487dae94427b9f716f70167ace6350423f88 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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 el
end

function figure(el)
    local images = pandoc.List()

    pandoc.walk_block(el, { Image = function(iel) images:insert(iel) end })

    return pandoc.RawBlock("html",
        "<figure class=\"c-figure\">\
            <a class=\"c-figure__link\" href=\"" .. images[1].src .. "\">\
                <img class=\"c-figure__image\" src=\"" .. images[1].src .. "\" title=\"" .. images[1].title .. "\" />\
            </a>\
        </figure>")
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