diff --git a/Project.toml b/Project.toml index e5d6aa2b..fcbf9bdc 100644 --- a/Project.toml +++ b/Project.toml @@ -14,6 +14,7 @@ Memoize = "c03570c3-d221-55d1-a50c-7939bbd78826" Requires = "ae029012-a4dd-5104-9daa-d747884805df" TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76" Tectonic = "9ac5f52a-99c6-489f-af81-462ef484790f" +URIs = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4" YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6" pandoc_crossref_jll = "f96e3c25-ae70-5588-8d8e-4a7ab3ba4c45" pandoc_jll = "c5432543-76ad-5c9d-82bf-db097047a5e2" @@ -28,6 +29,7 @@ Memoize = "0.4" Requires = "1.1" TOML = "1.0" Tectonic = "0.4" +URIs = "1" YAML = "0.4" julia = "1.6" pandoc_crossref_jll = "0.3.9" diff --git a/src/html.jl b/src/html.jl index 64c4d1ea..ce621eeb 100644 --- a/src/html.jl +++ b/src/html.jl @@ -1,4 +1,5 @@ import YAML +import URIs """ split_keepdelim(str::AbstractString, dlm::Regex) @@ -260,8 +261,10 @@ function fix_links(names, pages, url_prefix) elseif startswith(capture, "#ref-") page_link = "references" return uncapture("$url_prefix/$page_link.html$capture") - else + elseif URIs.URI(URIs.unescapeuri(capture)).scheme == "" return uncapture("$url_prefix$capture") + else + return uncapture(capture) end end fixed = replace(page, rx => replace_match) diff --git a/test/html.jl b/test/html.jl index 982e6e38..d310a6ae 100644 --- a/test/html.jl +++ b/test/html.jl @@ -61,6 +61,7 @@ Foo