A Lightweight Version of R Markdown

Render R Markdown to Markdown (without using 'knitr'), and Markdown to lightweight HTML or 'LaTeX' documents via the bundled 'cmark-gfm' library (instead of 'Pandoc'). Some missing Markdown features in 'cmark-gfm' are also supported, such as raw HTML or 'LaTeX' blocks, 'LaTeX' math, superscripts, subscripts, footnotes, element attributes, and appendices, but not all 'Pandoc' Markdown features are (or will be) supported. With additional JavaScript and CSS, you can also create HTML slides and articles. This package can be viewed as a trimmed-down version of R Markdown and 'knitr'. It does not aim at rich Markdown features or a large variety of output formats (the primary formats are HTML and 'LaTeX'). Book and website projects of multiple input documents are also supported.


  ______  
 /   ⚡  \
/litedown\
\   ⚡    /
 \______/

R Markdown Reimagined

CRANrelease litedown onr-universe R-CMD-check Build site Codecov testcoverage

litedown turns Markdown and R Markdown into HTML and LaTeX/PDF, with no knitr and no Pandoc. It imports only one R package, xfun, and renders Markdown with a bundled and patched copy of the cmark-gfm C library.

  • Computing: run code chunks and inline code in R, or in other languages via engines such as JavaScript, CSS, Mermaid, and shell commands. Chunk options control code, text output, figures, tables, caching, and even the order of execution.

  • Markdown: GFM plus math, footnotes, superscripts/subscripts, raw HTML/LaTeX blocks, element attributes, cross-references, citations, and callouts.

  • Output: single HTML documents (with resources embedded if you want), LaTeX and PDF, and lightweight HTML articles, slides, and paged HTML (for print), styled with small vanilla CSS/JS files from lite.js.

  • Projects: books and websites from a directory of documents with a _litedown.yml, including websites for R packages via pkg_site().

  • Workflow: roam() previews and renders documents in a browser, with live reload, so you do not need a Knit button.

Installation

install.packages('litedown')

The development version is available from r-universe:

install.packages('litedown', repos = 'https://yihui.r-universe.dev')

A quick look

Save this as hello.Rmd:

---
title: Hello litedown
output: html
---

```{r}
x = 2
```

The area of a circle with radius `{r} x` is `{r} pi * x^2`.

Then render it:

litedown::fuse('hello.Rmd')  # hello.Rmd -> hello.html
litedown::roam()             # or preview and render in a browser

Main functions

Function What it does
fuse() executes code in an R Markdown document, then renders it via mark() (like rmarkdown::render())
mark() renders Markdown to HTML, LaTeX, etc. (like Pandoc)
fiss() extracts code from a document (like knitr::purl())
roam() previews and renders documents in a browser
fuse_book(), fuse_site(), pkg_site() build books, websites, and package sites

If you do not compute in your documents, mark() alone is enough.

Learn more

Visit the package site, https://pkg.yihui.org/litedown/, which has the manual, the book litedown: R Markdown Reimagined, and examples.

Scope

I try to keep the R package small, and most planned features have been (re-)implemented so far, such as reports, slides, books, websites (including package sites), and paged HTML documents, etc. See the set $R$ below:

$$\mathrm{litedown} = \min{{R}} + {D_i} - {D_e} + {J}$$

Much of the functionality lives in CSS/JS, which makes litedown highly extensible and customizable: see Chapter 5 of the book for how to use the default assets and write your own. You are welcome to write your own CSS/JS, or contribute yours to lite.js so that everyone can use it.

Feature requests are welcome, too. I will take votes into consideration, so please upvote the features you like.

Acknowledgments

litedown was directly inspired by the packages in the set $R$ above. I wrote or co-wrote most of them, and learned a lot from the rest. Thanks to all their authors and contributors, and to the users whose questions, bug reports, and feedback over the years shaped the design of this package.

License

The litedown package is licensed under MIT.

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("litedown")

1.0 by Yihui Xie, a day ago


https://github.com/yihui/litedown


Report a bug at https://github.com/yihui/litedown/issues


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


Authors: Yihui Xie [aut, cre] , URL: https://yihui.org) , Tim Taylor [ctb] , John MacFarlane [cph] (Author of cmark) , Jeroen Ooms [ctb, cph] (Author of the R bindings to cmark in the commonmark package , from which the C glue code was adapted) , GitHub , Inc. [cph] (Author of the cmark-gfm extensions)


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports utils, xfun

Suggests rbibutils, rstudioapi, testit, tinyimg, tinytex


Imported by liteformats, markdown.

Suggested by CbKST, RWsearch, Rd2roxygen, ageutils, armadillo4r, atime, bigANNOY, bsplus, cpp4r, cusna, easybio, fastymd, flashr, flexsynth, grates, heplots, incidence2, knitr, kstIO, lt, mirai, mlr3resampling, nanonext, paws.common, piar, polyCub, rapr, rgeedim, rgeomorphon, ronfig, rsmatrix, sommer, sps, super, tinytable, wbstats, xfun, ympes.


See at CRAN