Markdown Parser and Renderer for R Graphics

Provides the mean to parse and render markdown text with grid along with facilities to define the styling of the text.


marquee

R-CMD-check CRANstatus Codecov testcoverage

marquee is a markdown parser and renderer for the R graphics engine. It can be used to render rich text formatted as markdown (CommonMark) inside R graphics such as ggplot2 or other graphics built on grid.

Installation

# You can install marquee from CRAN
install.packages("marquee")

# Or get the development version from Github using pak
pak::pak("r-lib/marquee")

Examples

The main function of the package is marquee_grob() which creates a grob based on markdown text and a style that can be rendered with grid:

# Let's render this readme
readme <- paste(readLines("README.Rmd")[-seq_len(17)], collapse = "\n")

library(marquee)
library(grid)

fancy_style <- classic_style(
  body_font = "baskerville",
  header_font = "marker felt",
  code_font = "fira code"
) |>
  modify_style("cb", background = linearGradient(
    colours = c("lightblue", "white"),
    x1 = 0, y1 = 1, x2 = 0, y2 = 0
  ))
grob <- marquee_grob(readme, style = fancy_style)
grid.draw(grob)

(The above is an image – go ahead and check)

Prior art

I would be remiss to not mention gridtext and ggtext, both by Claus Wilke. These packages aim to solve much the same problem as marquee, but work in a different way and don’t have the same powerful textshaping backend as marquee. Most notably from a user perspective is perhaps that gridtext understands HTML to some degree, whereas marquee is oblivious to both HTML and CSS. Instead, it supports the full CommonMark spec with the plan to add support for custom span elements as well.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("marquee")

1.2.1 by Thomas Lin Pedersen, a year ago


https://marquee.r-lib.org, https://github.com/r-lib/marquee


Report a bug at https://github.com/r-lib/marquee/issues


Browse source code at https://github.com/cran/marquee


Authors: Thomas Lin Pedersen [aut, cre] (ORCID: , Martin Mitáš [aut] (Author of MD4C) , Posit Software , PBC [cph, fnd] (ROR: <https://ror.org/03wc8by49>)


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports cli, glue, grDevices, grid, jpeg, lifecycle, png, rlang, S7, systemfonts, textshaping, utils, vctrs

Suggests ggplot2, gt, gtable, knitr, patchwork, ragg, rmarkdown, rsvg, testthat

Linking to cpp11


Suggested by ggdiagram, ggpmisc, ggrepel.


See at CRAN