summaryrefslogtreecommitdiffstats
path: root/scripts/subpages.lua
blob: 95f68f5be4bc99f83793be4657a0a6290c42f6bd (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
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) then el.src = siteUrl .. path.join({ namespace, el.src }) end

    return el
end

function link(el)
    if path.is_relative(el.target) then
        el.target = siteUrl .. path.join({ namespace, el.target })
    end

    return el
end

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