cleanrmd is a no-frills, lightweight HTML format for R Markdown, using class-less CSS.
This package was greatly inspired by Yuval Greenfield’s blog post: The Next CSS Frontier - Classless.
You can install the released version of cleanrmd from CRAN:
install.packages("cleanrmd")
You can install the latest development version from GitHub:
# install.packages("remotes")
::install_github("gadenbuie/cleanrmd") remotes
or from gadenbuie.r-universe.dev:
options(repos = c(
gadenbuie = 'https://gadenbuie.r-universe.dev',
CRAN = 'https://cloud.r-project.org'
))
install.packages('cleanrmd')
Create a new R Markdown document using the Clean HTML R
Markdown template in RStudio, or add the following to your
.Rmd
YAML header.
output:
cleanrmd::html_document_clean:
theme: no-class
To explore the available themes, set theme
to
NULL
.
output:
cleanrmd::html_document_clean:
theme: NULL
Syntax highlighting is provided by default by
pandoc, where syntax highlighting is performed during during the render,
minimizing dependencies. pandoc’s highlighting themes include
pygments
, tango
, espresso
,
zenburn
, kate
, monochrome
,
breezedark
, and haddock
. The
default
highlighting theme is arrow
, provided
by the rmarkdown
package in addition to the rstudio
theme.
html_document_clean()
can also use Prism for highlighting. In this case,
highlighting is performed in the browser and the dependencies are
downloaded as needed. To use Prism, set theme: prism
or use
one of the following value to choose a specific Prism theme:
prism-coy
, prism-dark
,
prism-funky
, prism-okaidia
,
prism-solarizedlight
, prism-tomorrow
, and
prism-twilight
.
MathJax and FontAwesome are also available but
disabled by default. To enable either feature, you can set
mathjax
to local
or default
, as
in rmarkdown::html_document()
. Set
use_fontawesome
to TRUE
to enable Font Awesome
icons.
output:
cleanrmd::html_document_clean:
mathjax: default
use_fontawesome: true
You can also load the CSS theme dependencies in other places where htmltools can be used to provide HTML dependencies, such as Shiny apps.
To include a theme in your app or page, use
::use_cleanrmd(theme = "new.css") cleanrmd
To view the list of theme options view the help pages of
?cleanrmd_themes()
or use its output:
::cleanrmd_themes()
cleanrmd#> [1] "almond" "awsm.css" "axist"
#> [4] "bamboo" "bullframe" "holiday"
#> [7] "kacit" "latex.css" "markdown-splendor"
#> [10] "markdown-retro" "markdown-air" "markdown-modest"
#> [13] "marx" "minicss" "new.css"
#> [16] "no-class" "picocss" "sakura"
#> [19] "sakura-vader" "semantic" "simplecss"
#> [22] "style-sans" "style-serif" "stylize"
#> [25] "superstylin" "tacit" "vanilla"
#> [28] "water" "water-dark" "writ"
The following CSS themes are included in this package and you can preview all 30 themes in one place here.