summaryrefslogtreecommitdiffstats
path: root/filters/headers.lua
blob: 4e3a6895448f2caaa10e63ecdb3085c7959b00b6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function Header(el)
    if el.level == 1 then
        local newchildren = pandoc.List()
        newchildren:insert(pandoc.Span(el.content, { class = 's-headlines__title-inner' }))
        el.content = newchildren
    end

    if el.level <= 3 and el.identifier ~= '' then
        el.content:insert(pandoc.Space())
        el.content:insert(pandoc.Link(pandoc.RawInline('html',
            '<svg class="o-icon" width="1em" height="1em"><use href="/symbols.svg#icon-link"></use></svg>'),
            '#' .. el.identifier, nil, { class = 's-headlines__link' }))
    end

    return el
end