prettify_Shiny {prettifyAddins}R Documentation

Prettify code using Shiny

Description

Prettify some code using a Shiny app.

Usage

prettify_Shiny(contents = NA, language = NA, tabSize = NULL, themeInfo = NULL)

Arguments

contents

the code to be prettified; there are three possibilities for this argument: NA (default), to use the file currently opened in RStudio; the path to a file; or the code given as a character vector

language

the language of the code, such as "javascript" or "JavaScript"; see getPrettifiableLanguages; if the contents are read from a file and language=NA, then the language is guessed from the file extension

tabSize

number of spaces of the indentation (usually 2 or 4); if NULL (the default), there are two possibilities: if the contents are read from the current file in RStudio, then the number of spaces will be the one you use in RStudio; otherwise it is set to 2

themeInfo

this argument is not important, it controls the theme of the Shiny app; it must be NULL or a list with two fields: editor, the name of a theme, and dark, a logical value, which tells whether the theme is dark

Value

The pretty code in a character string.

Examples

library(prettifyAddins)

code <- c(
  "function f(x){",
  "return x+1",
  "}"
)
if(interactive()){
  cat(prettify_Shiny(code, "javascript"))
}

[Package prettifyAddins version 2.6.1 Index]