ladybird/Meta/convert-markdown-links.lua
kleines Filmröllchen e430667923 Meta/build-manpages-website: Use absolute paths for all links
Previously, we had some broken cross-manpage links on the website after
the introduction of subsections. This is fixed by simply always using an
absolute path (leading '/') for links, making all images, icons and page
links work in all subsections.

Unfortunately, this change means that navigating the website build while
opening the files in the browser directly will no longer work. However,
a local static server such as `python -m http.server 8080` in the
output/ directory will work just fine for testing.
2023-01-08 13:35:29 +01:00

23 lines
631 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)
-- Images that are not icons are always copied to the website root.
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