summaryrefslogtreecommitdiff
path: root/Meta/convert-markdown-links.lua
blob: 166a9967764a7d829ea6b9702bc1b4c1a7b1a437 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function Link(el)
    el.target = string.gsub(el.target, "file:///bin/.*", "../cant-run-application.html")
    el.target = string.gsub(el.target, "help://man/([^/]*)/(.*)", "../man%1/%2.html")
    return el
end

function Image(el)
    -- HACK: Handle images that are not icons separately; they're copied manually in the
    --       Meta/build-manpages-website.sh script.
    --       Ideally this would be generalized so the paths export below could handle both.
    if el.src:find("^/res/icons/") == nil then
        el.src = "../" .. el.src
        return el
    end

    local pattern = "/res/icons/(.*)"
    local image = string.gsub(el.src, pattern, "%1")

    el.src = "../icons/" .. image
    file = io.open("icons.txt", "a+")
    file:write(image .. "\n")
    file:close()
    return el
end