repls = []
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
content = """
# # [Example](@id example-id)
# [foo](@ref), [bar](@ref bbaarr)
x = 1
"""
for repl in repls
content = replace(content, repl)
end
@assert content == """
# # Example
# foo, bar
x = 1
"""
content = """
# # [Example](@id example-id)
#
# [This is a long example which
# wraps a line](@ref)
#
# [In this case the](@ref reference also
# wraps a line)
#
# x = 1
"""
for repl in repls
content = replace(content, repl)
end
@assert content == """
# # Example
#
# This is a long example which
# wraps a line
#
# In this case the
#
# x = 1
"""
Fixes https://github.com/fredrikekre/Literate.jl/issues/224.
The new regexes have the following behavior: