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

Windows + Literate => Regex crash due to abspath escaped characters #181

Open
behinger opened this issue Jun 12, 2024 · 2 comments
Open

Comments

@behinger
Copy link

I get an error on the regexp ERROR: PCRE compilation error: \ at end of pattern for the literate part when running LiveServer.jl from several windows systems.

The reasons seems to lay in:
https://github.com/tlienart/LiveServer.jl/blob/eec3d5b23d16e296ba55c4f99084c1814bee5165/src/utils.jl#L249
which translates something like literate="Foo" to c:\\Foo\\. Unfortunately, this is not a correct regular expression, and thus later at
https://github.com/tlienart/LiveServer.jl/blob/eec3d5b23d16e296ba55c4f99084c1814bee5165/src/utils.jl#L165

the Regex(literate) throws the error (at what letter exactly is a bit surprisingly different on different windows machines / paths we tested... but haven't systematically tested it either).

I'm not entirely sure how to fix it, because I dont fully understand the function in L165. Maybe one can escape the sequence better?

PS: You can try that Regex("c:\\Foo\\") throws an error, or on windows machine Regex(abspath(".")) - note that sometimes it only complains about the last "\", but if you are unlikely and hit some special escaped things like "\F", it fails earlier ;)

@tlienart
Copy link
Collaborator

tlienart commented Oct 22, 2024

Hello, sorry for the delay in responding and thanks for the details

the stuff around L165:

  • takes a file at a path such as docs/literate/index.jl
  • reconstructs the expected corresponding md path at docs/src/index.md

I think the best path here would be to change

path = replace(spath[1], Regex("^$literate") => joinpath(foldername, "src")) 

with

path = joinpath(foldername, "src", chopprefix(spath[1], literate))

(I wasn't aware of chopprefix at the time of writing those lines)

julia> chopprefix("c:\\Foo\\Bar\\baz", "c:\\Foo\\")
"Bar\\baz"

would you be interested in trying this and opening a PR? thanks!

also cc @fredrikekre since it touches upon Literate and he's much more responsive than I 🙏

@behinger
Copy link
Author

behinger commented Nov 3, 2024

Thanks very much for looking into it. Right now is super stressful, I will try to keep a tab on this and if time is right I might come back to this. But right now it is too much for me to do an PR.

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