-
-
Notifications
You must be signed in to change notification settings - Fork 61
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
Literate does not strip notebook references when source spans multiple lines #224
Comments
For regex 2 and 3 it make sense, I think. Do you want to submit a PR? You can probably find some tests for these replacements that you can augment too. |
After some investigation, I would propose these three modified regexes: 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 In addition to including the trailing These have the following behavior: 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
""" |
For a notebook output, Literate will strip references for an input like this:
but not this:
The latter can appear when using a "line wrap" feature of an editor.
Perhaps this issue can be resolved if these regex's are allowed to span multiple lines: https://github.com/fredrikekre/Literate.jl/blob/master/src/Literate.jl#L212-L214
Specifically, can there be a trailing
s
on these three regex's?The text was updated successfully, but these errors were encountered: