Learn R Programming

marquee

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.

Copy Link

Version

Install

install.packages('marquee')

Monthly Downloads

311

Version

1.0.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Thomas Lin Pedersen

Last Published

January 20th, 2025

Functions in marquee (1.0.0)

geom_marquee

Draw text formatted with marquee
style_set

Create or modify a style set that describes a full markdown text
style

Create a style specification for a single tag
style-helpers

Helpers for defining styles
marquee_parse

Parse a text as marquee
marquefy_theme

Convert all text elements in a theme to marquee elements
GeomMarquee

Geom class for geom_marquee
marquee_glue

Marquee-aware string interpolation
guide_marquee

Marquee subtitle guide
marquee_grob

Construct a grob rendering one or more markdown texts
element_marquee

ggplot2 theme element supporting marquee syntax
classic_style

Classic styling for markdown
ink

Make justifications relative to the ink extent of the text
GuideMarquee

Guide class for guide_marquee
marquee-package

marquee: Markdown Parser and Renderer for R Graphics