litedown: A Minimal Re-implementation of the R Markdown Ecosystem

Yihui Xie

2025-04-09 @ Department of Statistics, UNL

The R Markdown ecosystem

classDiagram
  direction BT
  class htmlwidgets {
    +JS apps
    R-dep (26)
    web-dep (*.js/.css)
  }
  class rmarkdown {
    +HTML/LaTeX
    +RTF/Word/PowerPoint/EPub/...
    R-dep (knitr, evaluate, ... 25)
    sys-dep (Pandoc)
    web-dep (Bootstrap/jQuery/...)
  }
  class blogdown {
    +Websites
    R-dep (33)
    sys-dep (Hugo)
  }
  blogdown --|> bookdown
  class pagedown {
    +Paged HTML
    R-dep (38)
    web-dep (paged.js)
  }
  pagedown --|> bookdown
  class distill {
    +Grid layout
    R-dep (48)
    web-dep (distill)
  }
  distill --|> bookdown
  class pkgdown {
    +Package sites
    R-dep (52)
    web-dep (Bootstrap...)
  }
  pkgdown --|> rmarkdown
  class xaringan {
    +HTML slides
    R-dep (32)
    web-dep (remark.js)
  }
  xaringan --|> rmarkdown
  class tufte {
    +Two-column layout
    R-dep (26)
    web-dep (tufte.css)
  }
  tufte --|> rmarkdown
  class bookdown {
    +Books
    R-dep (26)
    web-dep (GitBook...)
  }
  bookdown --|> rmarkdown
  classDef default fill:none
  style rmarkdown fill:lightskyblue

A new minimal implementation

classDiagram
  class litedown {
    +HTML/LaTeX
    +min [ * ]
    R-dep (xfun, commonmark)
    web-dep (lite.js)
  }
  class rmarkdown {
    +[ * ]
  }
  class pkgdown {
    +[ * ]
  }
  class xaringan {
    +[ * ]
  }
  class tufte {
    +[ * ]
  }
  class blogdown {
    +[ * ]
  }
  class pagedown {
    +[ * ]
  }
  class distill {
    +[ * ]
  }
  class htmlwidgets {
    +[ * ]
  }
  class bookdown {
    +[ * ]
  }
  litedown *-- rmarkdown
  litedown *-- bookdown
  litedown *-- pkgdown
  litedown *-- xaringan
  litedown *-- tufte
  litedown *-- htmlwidgets
  litedown *-- blogdown
  litedown *-- pagedown
  litedown *-- distill
  rmarkdown <|-- bookdown
  rmarkdown <|-- pkgdown
  rmarkdown <|-- xaringan
  rmarkdown <|-- tufte
  rmarkdown <|-- htmlwidgets
  rmarkdown <|-- blogdown
  rmarkdown <|-- pagedown
  rmarkdown <|-- distill
  classDef default fill:none
  style litedown fill:lightcyan

Minimalism

Until we have begun to go without them, we fail to realize how unnecessary many things are. We’ve been using them not because we needed them but because we had them.

— Lucius Annaeus Seneca

It is not the man who has too little that is poor, but the one who hankers after more.

— Seneca, “Letters from a Stoic”


The two richest men in Omaha, Nebraska

  1. Warren Buffet

  2. ???

(if you think from the perspective of “degrees of freedom”…)


The path to richness

An example:1

knitr (<= v1.41)
  |> evaluate 
  |> highr 
  |> stringr 
    |> cli glue lifecycle magrittr rlang stringi vctrs 
  |> yaml 
  |> xfun 
knitr (> v1.41)
  |> evaluate 
  |> highr 
  |
  |
  |> yaml 
  |> xfun 

Heaviest object in the universe


Five books to summarize my career

A summary of my career 2011-2023


A brief history



R Markdown extensions, since 2016


Quarto (2022)


R Markdown in 2012 vs 2024

2012 2024
Output formats HTML HTML, LaTeX, PDF, Word, PowerPoint, EPUB, …
Applications Reports Reports, slides, articles, books, websites, dashboards, …
Backend sundown (a tiny C library) Pandoc (150+Mb)
R package dependencies (recursive) markdown: 0; knitr: 4 25
Package size ~2Mb ~83Mb

The above comparison does not include R Markdown extension packages such as bookdown and blogdown, which are even heavier.


⚡ litedown ⚡ (2024)

Make Markdown HTML Again

Do one thing, and do it well


In HTML I Trust

Do you know how awesome web browsers are?…

(now cast the spell “go up”, “go down”, “dark mode”, “mirror my slides”, “edit my slides”, “hi *anyone…” (voice input), or “reset my slides”)


Minimalism: my new journey

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




Demos

# install from CRAN
install.packages('litedown')
# or install the dev version (recommended for now)
install.packages('litedown', repos = 'https://yihui.r-universe.dev')

Custom execution order of code

I don’t have enough time showcase all possibilities of litedown, so let me highlight one tiny feature that I came up with when rethinking about literate programming.

---
title: A nice report
abstract: "In this report, we studied `{r} nrow(x)` cars."
---

Filter cars with `mpg` above 20.

```{r, order = 0}
x = subset(mtcars, mpg > 20)
```

Thank you!

https://yihui.org

  1. One Fewer Dependency of knitr (blog post): https://yihui.org/en/2023/01/knitr-stringr/

  2. litedown only depends on xfun and commonmark.

  3. Much stabler than Pandoc. Maintaining compatibility with new Pandoc releases has not been easy in R Markdown.