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

Parsing fails for multiline comments and markdown with windows linebreaks #165

Closed
DrChainsaw opened this issue Aug 9, 2021 · 1 comment

Comments

@DrChainsaw
Copy link

Thanks for this awesome package. Very powerful and easy to use!

Seems like the regex does not catch windows line breaks. As a piece of clear evidence that computers are consipiring against us, the method used in testing serves as a workaround :/

julia> mdstr = """
           md\"\"\"
           bla
           \"\"\"
           """

julia> mktempdir() do path
       testfile = joinpath(path,"testfile.md")
       write(testfile, mdstr)
       match(r"^md\"\"\"$\R^(\X*?)\R^\"\"\"$"m, read(testfile, String))
       end
RegexMatch("md\"\"\"\nbla\n\"\"\"", 1="bla")

# This file is created using "new file" in VS code
julia> read("mdtest.jl", String)
"md\"\"\"\r\nbla\r\n\"\"\""

julia> match(r"^md\"\"\"$\R^(\X*?)\R^\"\"\"$"m, read("mdtest.jl", String))

The regex works when tested in Rubular. Replacing \R with (?:\r?\n) does nothing, but removing the begin/end of line markers makes it work.

This seems to be a way to create windows linebreaks inside Julia:

julia> mdstr = "md\"\"\"\r\nbla\r\n\"\"\""
"md\"\"\"\r\nbla\r\n\"\"\""

julia> mdstr == read("mdtest.jl", String)
true

julia> mktempdir() do path
       testfile = joinpath(path,"testfile.md")
       write(testfile, mdstr)
       match(r"^md\"\"\"$\R^(\X*?)\R^\"\"\"$"m, read(testfile, String))
       end
@fredrikekre
Copy link
Owner

Thanks, I thought it was happening after (

push!(repls, "\r\n" => "\n") # normalize line endings
) but that is just pushing replacements to a vector and doing the replacement later

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

No branches or pull requests

2 participants