as_dict: Construct dictionary

View source: R/highlight.R

as_dictR Documentation

Construct dictionary

Description

Construct a dictionary which controls the highlighting of text.

Usage

as_dict(
  x,
  feature = "feature",
  bg_colour = "bg_colour",
  txt_colour = "txt_colour",
  bold = "bold",
  italic = "italic",
  strike_out = "strike_out"
)

Arguments

x

A data.frame with columns of switches to determine text highlighting. Not all columns need to be present.

feature

Name of column that contains the words of terms to highlight.

bg_colour

Name of column that controls the background colour for a feature

txt_colour

Name of column that controls the text colour for a feature.

bold

Name of column that controls if a feature is printed with bold font.

italic

Name of column that controls if a feature is printed with italic font.

strike_out

Name of column that controls if a feature is printed struck out.

Details

The columns "bold", "italic" and "strike_out" need to contain logical values (i.e. TRUE/FALSE)

Examples

df <- data.frame(
  feature = c("good", "bad"),
  bg_colour = c("green", "red"),
  txt_colour = c("grey", "blue"),
  bold = TRUE,
  italic = TRUE,
  strike_out = TRUE,
  stringsAsFactors = FALSE
)
mydict <- as_dict(df)

JBGruber/highlightr documentation built on Oct. 11, 2022, 2:53 a.m.