summaryrefslogtreecommitdiffstats
path: root/filters/emojis.lua
blob: 286a87bbc4b250eca696bb921b6b1703a83fcbf6 (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
local common = require 'scripts.lib.common'

local vars = {}

function meta(meta) vars = meta end

function str(el)
    if vars.build and vars.build.file_out:match(".xml$") then
        return el
    end

    local prefix, emojiref, suffix = el.text:match('^(.*):([^ ]+):(.*)$')

    if emojiref then
        local els = pandoc.List()

        els:insert(pandoc.Str(prefix))
        els:insert(pandoc.Image(emojiref, "/assets/emojis/" .. emojiref .. ".png", emojiref, { class = 'o-emoji' }))
        els:insert(pandoc.Str(suffix))

        return els
    end

    return el
end

return { { Meta = meta }, { Str = str } }