Skip to content

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

@DrChainsaw

Description

@DrChainsaw

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions