highlight: Text highlighter

View source: R/highlight.R

highlightR Documentation

Text highlighter

Description

Text highlighter

Usage

highlight(
  text,
  dict,
  id = NULL,
  case_insensitive = TRUE,
  output = c("html", "tex", "ggplot", "plot"),
  return = FALSE
)

hightlight_html(text, dict, id = NULL, case_insensitive = TRUE, return = FALSE)

hightlight_tex(text, dict, id = NULL, case_insensitive = TRUE, return = FALSE)

hightlight_plot(text, dict, id = NULL, case_insensitive = TRUE, return = FALSE)

Arguments

text

A text to be printed with highlighted words.

dict

A data.frame with columns "word" and "colour".

id

A vector of ids which are displayed as headlines.

case_insensitive

Should search for feature be case insensitive?

output

Choose output format.

return

Should the code be returned as an object.

Examples

text <- c("This is a good test with some bad words",
          "bad is red and good is green")
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)
highlight(text, mydict)


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