Skip to contents

An R Markdown format for literate JavaScript programming. With default settings, each JavaScript chunk is run in its own environment and any output written with console.log() is inserted in the HTML document as the code runs. In this setting, the JavaScript is rendered directly in the browser at view time.

A similar effect can be achieved by using the js_live = FALSE chunk option to instead run the JavaScript code using node at compile time. In this setting, the results printed by the node process are captured and stored in the document, resulting in a non-dynamic output that captures the results of the JavaScript runtime code.

In both of the above settings, each code chunk is run separately. You can use the js_redirect = FALSE knitr chunk option to disable the console.log() redirect and use the standard JavaScript engine included in the knitr package. Logged statements will still be available in the browser's devolper tools console, as this engine is equivalent to having entered the JavaScript code directly into the HTML source within a <script> tag.


  theme = NULL,
  css = NULL,
  toc = FALSE,
  toc_depth = 3,
  mathjax = NULL,
  use_fontawesome = FALSE,
  use_google_fonts = FALSE,
  highlight = "haddock",
  fig_width = 10,
  fig_height = 7,
  fig_retina = 2,
  keep_md = FALSE,
  dev = "png",
  pandoc_args = NULL,
  extra_dependencies = NULL



Additional function arguments to pass to the base R Markdown HTML output formatter html_document_base




One or more css files to include


TRUE to include a table of contents in the output


Depth of headers to include in table of contents


Include mathjax. The "default" option uses an https URL from a MathJax CDN. The "local" option uses a local version of MathJax (which is copied into the output directory). You can pass an alternate URL or pass NULL to exclude MathJax entirely.


Should FontAwesome be included? Default is FALSE.


Should fonts hosted on Google Fonts be included? Default is FALSE, where only system fonts will be used.


One of the pandoc highlight styles.


Default width (in inches) for figures


Default height (in inches) for figures


Scaling to perform for retina displays (defaults to 2, which currently works for all widely used retina displays). Set to NULL to prevent retina scaling. Note that this will always be NULL when keep_md is specified (this is because fig_retina relies on outputting HTML directly into the markdown document).


Keep the markdown file generated by knitting.


Graphics device to use for figure output (defaults to png)


Additional command line options to pass to pandoc


Additional function arguments to pass to the base R Markdown HTML output formatter html_document_base