prettify_V8: Prettify code using V8

Description Usage Arguments Value Examples

View source: R/prettify_V8.R

Description

Prettify some code using the V8 package.

Usage

1
prettify_V8(contents = NA, language = NA, tabSize = 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"; 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

Value

The pretty code in a character string.

Examples

1
2
3
4
5
6
7
8
library(prettifyAddins)

code <- c(
  "function f(x){",
  "return x+1",
  "}"
)
cat(prettify_V8(code, "JavaScript"))

prettifyAddins documentation built on Jan. 25, 2022, 5:09 p.m.