← Back to all sparks
D

downlit

INFRA · APIS
Velocity0.0

Syntax highlighting and automatic linking of R code to documentation

downlit's HTML contract was set in 0.4.0; every release since tracks R itself.

syntax highlightingpkgdowndocumentationautolinkingr toolchain
Current state
downlit does syntax highlighting and automatic linking of R code to documentation, and is the engine behind pkgdown's code blocks. Version 0.4.0 restructured its output into the class taxonomy themes style against, and 0.4.1 completed it with base pipe support and per-line spans. The three releases since are compatibility fixes for R and R-devel.
Where it's heading
The package reached its intended shape in the 0.4.x pair and has been static since. Its work now is reacting to the language and toolchain: a new pipe operator to highlight, an R-devel change to survive, a UTF-8 parsing crash routed around by simplifying the algorithm. Autolinking coverage, which drew steady contributions through 0.4.1, has not been extended since 2022.
Prediction
Expect the next release to track another R or pandoc change rather than extend highlighting or linking.

Recent moves

  1. 2y ago

    Parsing simplified for R 4.0 to avoid a UTF-8 crash

    Falls back to a simpler parsing algorithm on R 4.0 to avoid crashing on certain UTF-8 characters. A defensive fix, and the most recent activity in the visible window.

    View source ↗
  2. 3y ago

    Fix for upcoming R-devel

    A single fix to stay compatible with the then-upcoming R-devel. Characteristic of the package's post-0.4.1 cadence.

    View source ↗
  3. 4y ago

    highlight() no longer errors on uninstalled packages

    Stops highlight() erroring when a package it infers to be attached is not installed, and corrects linking for requireNamespace(). Robustness fixes on the paths pkgdown exercises most.

    View source ↗
  4. 4y ago

    Base pipe |> highlighted; per-line spans match pandoc

    Adds highlighting for the base pipe, gives every line and every multi-line token its own span to match pandoc's structure, and stops truncating very long tokens. Together with a run of autolink corrections, this finished the output overhaul 0.4.0 began.

    View source ↗
  5. 4y ago

    Highlighting restructured into r-in/r-out/r-msg CSS classes

    Rebuilds the highlighting output around a class taxonomy, wrapping each line as input, output, plot, message, warning or error, and minimises the default styling of conditions so themes can restyle them. This is the release that defined the HTML contract pkgdown themes have targeted ever since.

    View source ↗
  6. 5y ago

    Vignette autolinking and forced highlighting via div class

    Teaches autolinking to resolve vignette(foo) against attached packages and lets any pre block be highlighted by wrapping it in a downlit-classed div. Both address cases where the surrounding document made highlighting hard to trigger.

    View source ↗