reindent_chromote {prettifyAddins} | R Documentation |
Reindent code using chromote
Description
Reindent some code using chromote.
Usage
reindent_chromote(contents = NA, language = NA, tabSize = NULL)
Arguments
contents |
the code to be reindented; there are three possibilities for
this argument:
|
language |
the language of the code, such as |
tabSize |
number of spaces of the indentation (usually |
Value
The reindented code in a character string.
Note
This function uses chromote::find_chrome()
to find the
executable of Google Chrome or another Chromium-based browser. If it is
not found you will get an error. In this case set the environment variable
CHROMOTE_CHROME
to the path of such an executable
(e.g. Sys.setenv(CHROMOTE_CHROME = "path/to/chrome.exe")
).
Examples
library(prettifyAddins)
code <- c(
'if test == 1:',
'print "it is one"',
'else:',
'print "it is not one"'
)
if(Sys.which("chrome") != "") {
cat(reindent_chromote(code, "python"))
}