summaryrefslogtreecommitdiffstats
path: root/filters/emojis.lua
blob: 24a9fc30c7603207eec0ff8cd6eda3255b0f553d (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, "/emojis/" .. emojiref .. ".png", emojiref, { class = 'o-emoji' }))
        els:insert(pandoc.Str(suffix))

        return els
    end

    return el
end

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