flair: Formats source code

Description Usage Arguments Details Value Examples

View source: R/flair.R

Description

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

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
flair(x, pattern, before = NULL, after = NULL, ...)

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

## S3 method for class 'with_flair'
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 '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

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.

Value

A string with formatting wrappers.

Examples

1
2
3
4
5
6
7
code_string <- "foo <- mean(1:10, na.rm = TRUE)"

code_string %>% flair("foo")

code_string %>% flair_args()

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

flair documentation built on April 24, 2020, 1:06 a.m.