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

Adjust parse so that it can process Windows EOLs #124

Open
sjentsch opened this issue May 19, 2024 · 2 comments
Open

Adjust parse so that it can process Windows EOLs #124

sjentsch opened this issue May 19, 2024 · 2 comments
Labels
bug an unexpected problem or unintended behavior

Comments

@sjentsch
Copy link

sjentsch commented May 19, 2024

Currently, parse_all (strictly speaking the evaluation of the parsed string) fails if x contains Windows EOL-markers (\r\n). In order to prevent this, this line

x <- unlist(strsplit(x, "\n"), recursive = FALSE, use.names = FALSE)
could be changed so that it accepts either \n or \r\n as split characters:
x <- unlist(strsplit(x, "\n|\r\n"), recursive = FALSE, use.names = TRUE)

I understand that this rarely would happen (R-functions generally handle Windows-EOLs correctly). The error may however occur if the syntax to be evaluated is copied from the clipboard. Another example where the error can occur is the jamovi module Rj (https://github.com/jonathon-love/Rj). I could also fix it there, but I thought it may be better to handle it in parse_all.

R-code for producing the error:
evaluate::evaluate(paste(readLines("https://raw.githubusercontent.com/sjentsch/examples4jamovi/main/Factor%20analysis/Syntax_CheckCorrelations.R"), collapse = "\r\n"))

@hadley
Copy link
Member

hadley commented Jun 14, 2024

Do you want to try doing a PR?

@hadley hadley added the bug an unexpected problem or unintended behavior label Jun 14, 2024
@sjentsch
Copy link
Author

sjentsch commented Jun 14, 2024

Yes, I will do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants