A Minimal Example for Markdown

This is a minimal example of using highlightr to produce an PDF document from Markdown.

Define custom dictionary and highlight text

library(highlightr)

text <- c("This is a good test with some bad words.",
          "The word 'bad' has red background and white font colour.",
          "The word 'good' has #77dd77 (green) background, font colour #00008b (blue).",
          "Both 'bad' and 'good' are bold and italic",
          "The word 'important' is bold and 'urgent' is italic.")

dict <- as_dict(data.frame(
  feature = c("good", "bad", "important", "urgent"),
  bg_colour = c("#77dd77", "red", "", ""),
  txt_colour = c("#00008b", "white", "", ""),
  bold = c(TRUE, TRUE, TRUE, FALSE),
  italic = c(TRUE, TRUE, FALSE, TRUE),
  strike_out = TRUE, # is currently ignored
  stringsAsFactors = FALSE
))

highlight(text, dict, output = "tex")


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