summaryrefslogtreecommitdiffstats
path: root/filters/macros.lua
blob: 2864befa1d23736d31ad801a3e2ddba8dd8335ae (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
function note(el)
    el.classes = pandoc.List()
    el.classes:insert("c-note")
    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><a href=\"" .. images[1].src .. "\"><img src=\"" .. images[1].src .. "\" title=\"" ..
            images[1].title .. "\" /></a></figure>")
end

function Div(el)
    if el.classes:includes("note") then
        el = note(el)
    elseif el.classes:includes("figure") then
        el = figure(el)
    end

    return el
end