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

Correctly handle refs that span multiple lines #233

Merged
merged 1 commit into from
Jan 3, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Literate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,9 @@ function replace_default(content, sym;
# Run some Documenter specific things
if !isdocumenter(config)
## - remove documenter style `@ref`s and `@id`s
push!(repls, r"\[(.*?)\]\(@ref\)" => s"\1") # [foo](@ref) => foo
push!(repls, r"\[(.*?)\]\(@ref .*?\)" => s"\1") # [foo](@ref bar) => foo
push!(repls, r"\[(.*?)\]\(@id .*?\)" => s"\1") # [foo](@id bar) => foo
push!(repls, r"\[([^]]+?)\]\(@ref\)"s => s"\1") # [foo](@ref) => foo
push!(repls, r"\[([^]]+?)\]\(@ref .*?\)"s => s"\1") # [foo](@ref bar) => foo
push!(repls, r"\[([^]]+?)\]\(@id .*?\)"s => s"\1") # [foo](@id bar) => foo
end

# do the replacements
Expand Down
11 changes: 11 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ content = """
#nb # %% [markdown] {"meta": "data"}
#nb # # Explicit markdown cell with metadata

# It can sometimes happen that a text editor line-wraps [a link which shouldn't
# break](@ref bbaarr)

#=
First multiline
comment
Expand Down Expand Up @@ -441,6 +444,11 @@ const GITLAB_ENV = Dict(
@test occursin("# \\int f(x) dx", script)
@test occursin("# First multiline", script)
@test occursin("# Second multiline comment", script)
@test occursin(
"""
# It can sometimes happen that a text editor line-wraps a link which shouldn't
# break""",
script)

# mdstrings
mdstrings_file = "inputfile_mdstrings.jl"
Expand Down Expand Up @@ -631,6 +639,9 @@ end end
hidden2 * hidden2
````

It can sometimes happen that a text editor line-wraps [a link which shouldn't
break](@ref bbaarr)

First multiline
comment

Expand Down