prettycode
prettycode copied to clipboard
Fix multiline strings (common) and symbols (not common I hope)
I believe that might be the issue I wanted to report. In the following code snippet, only the first line is highlighted: "hourly <- input %>%\n mutate(timestamp = floor_date(timestamp, "hours")) %>%\n group_by(meter, timestamp) %>%\n summarise(usage = sum(usage))"
@lbartnik
This works file for me:
f <- function() {
hourly <- input %>%
mutate(timestamp = floor_date(timestamp, "hours")) %>%
group_by(meter, timestamp) %>%
summarise(usage = sum(usage))
}
f
I run it on a string which is pre-formatted, so I only thought of adding syntax highlighting but not of re-formatting.

It isn't clear to me what is intended here. The cat screenshot isn't a function, so it isn't clear to me how {prettycode} would impact it.
Reprex:
f <- function() {
print("Multiline
strings
are
ok")
}
highlight(deparse(f))
#> [1] "\033[31mfunction\033[39m \033[33m(\033[39m\033[33m)\033[39m "
#> [2] "\033[33m{\033[39m"
#> [3] " \033[36mprint\033[39m\033[34m(\033[39m\033[33m\"Multiline\\n strings\\n are \\n ok\"\033[39m\033[34m)\033[39m"
#> [4] "\033[33m}\033[39m"
The multi-line string is collapsed into a single line.