Learn R Programming

flair (version 0.0.2)

flair: Formats source code

Description

Adds decorative formatting to parts of a string or source code.

Usage

flair(x, pattern, before = NULL, after = NULL, ...)

flair_rx(x, pattern, before = NULL, after = NULL, ...)

# S3 method for with_flair flair_rx(x, pattern, before = NULL, after = NULL, ...)

# S3 method for default flair_rx(x, pattern, before = NULL, after = NULL, ...)

flair_quick(x, pattern, before = NULL, after = NULL, ...)

flair_all(x, ...)

# S3 method for default flair_all(x, ...)

# S3 method for with_flair flair_all(x, ...)

flair_args(x, ...)

flair_funs(x, ...)

flair_input_vals(x, ...)

Arguments

x

A string or with_flair object

pattern

A pattern to match. By default, this is a fixed pattern; use flair_rx for regular expressions.

before

String giving specific html tags to insert before matched text.

after

String giving specific html tags to insert after matched text.

...

Formatting style options, passed to txt_style

Value

A string with formatting wrappers.

Details

If input is a string object, flair returns a formatted string.

If input is a with_flair object, flair returns a with_flair object with the source elements formatted.

Currently, flair is only built for html formatting.

Examples

Run this code
# NOT RUN {
code_string <- "foo <- mean(1:10, na.rm = TRUE)"

code_string %>% flair("foo")

code_string %>% flair_args()

code_string %>% flair_funs(color = "red")
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab