The autolinker is built around two XPath expressions:

  • //pre[contains(@class, 'r')]: this finds all <div>s with class sourceCode and r. The contents must be syntax-highlighted using pygments. (This is default in rmarkdown::html_document() when theme = NULL.)

  • .//code[count(*) = 0]: this finds all <code> that contain only text (and no other tags).

autolink_html(input, output = input, local_packages = character())


input, output

Input and output paths for HTML file


A named character vector providing relative paths (value) to packages (name) that can be reached with relative links from the target HTML document.


Currently the following expressions are linked:

  • Function calls, foo()

  • Function calls qualified with the package name, bar::foo()

  • Symbols qualified with the package name, bar::baz

  • library(), require() and requireNamespace() calls.

  • Help calls, ?foo, package?foo, ?bar::foo, help(foo), help(foo, package = bar), help(package = bar).

  • Vignette calls, vignette(baz), vignette(baz, package = "bar")

Calls to library() and require() are used to find the topics connected to unqualified references.


if (FALSE) { autolink_html("path/to/file.html", local_packages = c( shiny = "shiny", shinydashboard = "shinydashboard" ) ) }