ladybird/Meta/convert-markdown-links.lua
Linus Groh f377951178 Meta: Update manpages website build script to handle non-icon images
Adding an image to man7/Audio-subsystem.md referencing a non-icon image
file in the same directory broke the automated build of the manpages
website, which was not prepared to handle this case.
2022-05-29 10:24:31 +02:00

24 lines
800 B
Lua

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