From 239fbf87ce3e62d3e5f3d9e2484ff41c80242ff4 Mon Sep 17 00:00:00 2001 From: Julius Krumbiegel Date: Thu, 16 May 2024 15:53:44 +0200 Subject: [PATCH] testing out relative link changes --- docs/buildutils/relative_links.jl | 10 +++++----- docs/makedocs.jl | 4 +++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/buildutils/relative_links.jl b/docs/buildutils/relative_links.jl index 62d3ddaa3af..db17dd2c352 100644 --- a/docs/buildutils/relative_links.jl +++ b/docs/buildutils/relative_links.jl @@ -40,14 +40,14 @@ function make_relative(s, here) end """ -Replaces all absolute links in all html files in the __site folder with +Replaces all absolute links in all html files in the build folder with relative links. """ -function make_links_relative() +function make_links_relative(buildfolder) invalid_relative_links = Dict{String,Pair{String,String}}() function check_local_link!(invalid_relative_links, file_location, link) - link_without_id = replace(link, r"#[a-zA-Z0-9!_\-\(\)]*$" => "") + link_without_id = replace(link, r"#.*$" => "") absolute_link = if startswith(link, "/") replace(link_without_id, r"^/+" => "") else @@ -69,7 +69,7 @@ function make_links_relative() !startswith(link, "data:") && !startswith(link, r"https?") && !startswith(link, "#") end - cd("__site") do + cd(buildfolder) do for (root, _, files) in walkdir(".") path = join(splitpath(root)[2:end], "/") @@ -128,7 +128,7 @@ function make_links_relative() end if !isempty(invalid_relative_links) - error("Found invalid relative links: \n$(join(invalid_relative_links, "\n"))") + @warn("Found invalid relative links: \n$(join(invalid_relative_links, "\n"))") end return diff --git a/docs/makedocs.jl b/docs/makedocs.jl index 64a37e1bf34..5549b8845ea 100644 --- a/docs/makedocs.jl +++ b/docs/makedocs.jl @@ -11,6 +11,8 @@ using Documenter.MarkdownAST using Documenter.MarkdownAST: @ast using DocumenterVitepress using Markdown +# using Gumbo +# using AbstractTrees # include("buildutils/deploydocs.jl") # include("buildutils/relative_links.jl") @@ -183,7 +185,7 @@ makedocs(; # # at the time, link relatively within `stable` so that users don't accidentally # # copy & paste versioned links if they started out on `stable` # @info "Rewriting all absolute links as relative" -# make_links_relative() +# make_links_relative(joinpath("build", "final_site")) # generate_redirects([ # "/reference/index.html" => "/examples/index.html",