evaluate icon indicating copy to clipboard operation
evaluate copied to clipboard

Adjust parse so that it can process Windows EOLs

Open sjentsch opened this issue 1 year ago • 2 comments

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 https://github.com/r-lib/evaluate/blob/166dd16140aaf1345b6c045eccdfc88d12a5c84d/R/parse.R#L28 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"))

sjentsch avatar May 19 '24 15:05 sjentsch

Do you want to try doing a PR?

hadley avatar Jun 14 '24 19:06 hadley

Yes, I will do.

sjentsch avatar Jun 14 '24 19:06 sjentsch