flair: Formats source code

View source: R/flair.R

flairR Documentation

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 class 'decorated'
flair_rx(x, pattern, before = NULL, after = NULL, ...)

## Default S3 method:
flair_rx(x, pattern, before = NULL, after = NULL, ...)

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

flair_all(x, ...)

## Default S3 method:
flair_all(x, ...)

## S3 method for class 'decorated'
flair_all(x, ...)

flair_args(x, ...)

flair_funs(x, ...)

flair_input_vals(x, ...)

Arguments

x

A string or decorated 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

Details

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

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

Currently, flair is only built for html formatting.

Value

A string with formatting wrappers.

Examples


code_string <- "foo <- mean(1:10, na.rm = TRUE)"

code_string %>% flair("foo")

code_string %>% flair_args()

code_string %>% flair_funs(color = "red")



kbodwin/flair documentation built on Feb. 6, 2023, 4:24 p.m.