https://github.com/r-lib/marquee
Markdown Parser and Renderer for R Graphics
https://github.com/r-lib/marquee
Last synced: about 1 year ago
JSON representation
Markdown Parser and Renderer for R Graphics
- Host: GitHub
- URL: https://github.com/r-lib/marquee
- Owner: r-lib
- License: other
- Created: 2024-04-16T20:01:24.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-04-23T12:29:42.000Z (about 1 year ago)
- Last Synced: 2025-04-23T13:42:57.676Z (about 1 year ago)
- Language: C
- Homepage: https://marquee.r-lib.org
- Size: 26.4 MB
- Stars: 90
- Watchers: 6
- Forks: 4
- Open Issues: 19
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
dev = "ragg_png",
dpi = 300
)
```
# marquee 
[](https://github.com/r-lib/marquee/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/r-lib/marquee?branch=main)
[](https://app.codecov.io/gh/r-lib/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
``` r
# 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:
```{r, fig.asp=2}
# 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](https://github.com/wilkelab/gridtext)
and [ggtext](https://github.com/wilkelab/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](https://spec.commonmark.org/) with the plan to add support for
custom span elements as well.