Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not fix link when the uri contains a schema #109

Merged
merged 5 commits into from
May 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
5 changes: 4 additions & 1 deletion src/html.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import YAML
import URIs

"""
split_keepdelim(str::AbstractString, dlm::Regex)
Expand Down Expand Up @@ -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 == ""
rikhuijzer marked this conversation as resolved.
Show resolved Hide resolved
return uncapture("$url_prefix$capture")
else
return uncapture(capture)
end
end
fixed = replace(page, rx => replace_match)
Expand Down
3 changes: 3 additions & 0 deletions test/html.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
<link rel="stylesheet" href="/files/style.css"/>
<a href="#sec:foo">Foo</a>
<h2 data-number="3.5" id="sec:foo"><span class="header-section-number">3.5</span> Foo</h2>
<p> <a href="https://www.google.com">Jump</a></p>
"""
pages = [page]
docs_dir = joinpath(pkgdir(Books), "docs")
Expand All @@ -73,6 +74,7 @@
<link rel="stylesheet" href="/Books.jl/files/style.css"/>
<a href="/Books.jl/test.html#sec:foo">Foo</a>
<h2 data-number="3.5" id="sec:foo"><span class="header-section-number">3.5</span> Foo</h2>
<p> <a href="https://www.google.com">Jump</a></p>
Copy link
Member Author

@findmyway findmyway May 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line will become the following line without this PR:

<a href="/Books.jlhttps://www.google.com">Jump</a></p>

@rikhuijzer

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I get it! Good addition and nice that you've added a test too 😄 💯

"""
@test actual == expected
end
Expand All @@ -83,6 +85,7 @@
<link rel="stylesheet" href="/files/style.css"/>
<a href="/test.html#sec:foo">Foo</a>
<h2 data-number="3.5" id="sec:foo"><span class="header-section-number">3.5</span> Foo</h2>
<p> <a href="https://www.google.com">Jump</a></p>
"""
@test actual == expected
end
10 changes: 6 additions & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ DocMeta.setdocmeta!(
)
doctest(Books)

include("output.jl")
include("html.jl")
include("showcode.jl")
include("generate.jl")
@testset "Books.jl" begin
include("output.jl")
include("html.jl")
include("showcode.jl")
include("generate.jl")
end