Browse Source

Correctly handle refs that span multiple lines

pull/233/head
Kipton Barros 2 years ago
parent
commit
8eae1c4bf3
  1. 6
      src/Literate.jl
  2. 11
      test/runtests.jl

6
src/Literate.jl

@ -211,9 +211,9 @@ function replace_default(content, sym; @@ -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

11
test/runtests.jl

@ -262,6 +262,9 @@ content = """ @@ -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
@ -441,6 +444,11 @@ const GITLAB_ENV = Dict( @@ -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"
@ -631,6 +639,9 @@ end end @@ -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

Loading…
Cancel
Save