View source: R/prettify_chromote.R
reindent_chromote | R Documentation |
Reindent some code using chromote.
reindent_chromote(contents = NA, language = NA, tabSize = NULL)
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 |
The reindented code in a character string.
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")
).
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"))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.