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

Conversation

kbarros
Copy link
Contributor

@kbarros kbarros commented Jan 3, 2024

Fixes #224.

The new regexes have the following behavior:

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
    """

@fredrikekre fredrikekre merged commit ff4a1c2 into fredrikekre:master Jan 3, 2024
8 checks passed
@fredrikekre
Copy link
Owner

Thanks, will make a new release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Literate does not strip notebook references when source spans multiple lines
2 participants