yihui / formatR

Format R Code Automatically
https://yihui.org/formatr/
255 stars 52 forks source link

Incorrect deparse'd output #5

Closed cameronbracken closed 13 years ago

cameronbracken commented 13 years ago

When keep.space=T I noticed that incorrect output is being generated:

> require(formatR)
> options(keep.space=TRUE)
> deparse.tidy(parse.tidy(text="\t\t# comment")[[1]])
[1] "\\t\\t# comment"

When it should be

"\t\t# comment"
yihui commented 13 years ago

Although simply replacing \\\\t with \t is a brutal solution and has side effects, I did it anyway.

Do you know any way to only replace the \\\\t before #? I don't know how to write such a regular expression.

Thanks!

cameronbracken commented 13 years ago

I am quite bad with regular expressions and so would not be much help there. I think the times in which this would come up are very small though so the impact will be minimal.

yihui commented 13 years ago

OK. I decided only to turn on this feature only if keep.space = TRUE so the probability will be even smaller.

cameronbracken commented 13 years ago

Cool, that is what I was imagining as well.