summaryrefslogtreecommitdiffstats
path: root/scripts/content.lua
blob: d77759d91cd4919f279f1f6b1069cacd4da243e2 (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 path = require 'pandoc.path'

local namespace = ''
local siteUrl = ''

function meta(meta)
    namespace = pandoc.utils.stringify(meta.namespace)
    siteUrl = pandoc.utils.stringify(meta.site.url):gsub("/$", "")
end

function image(el)
    if path.is_relative(el.src) and not el.src:match("^https?://") then
        el.src = siteUrl .. path.join({ namespace, el.src })
    end

    return el
end

function link(el)
    if path.is_relative(el.target) and not el.target:match("^https?://") then
        el.target = siteUrl .. path.join({ namespace, el.target })
    end

    return el
end

return { { Meta = meta }, { Image = image, Link = link } }