-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathREADME.Rmd
75 lines (59 loc) · 2.33 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
dev = "ragg_png",
dpi = 300
)
```
# marquee <img src="man/figures/logo.png" align="right" height="138" alt="" />
<!-- badges: start -->
[![R-CMD-check](https://github.com/r-lib/marquee/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/marquee/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/r-lib/marquee/branch/main/graph/badge.svg)](https://app.codecov.io/gh/r-lib/marquee?branch=main)
<!-- badges: end -->
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.