Many of you have heard about RStudio’s latest release and it’s new R Markdown feature. Today, I’d like to announce the markdown package for R, a tool for converting Markdown documents to HTML, created in collaboration with RStudio. It offers the complete R Markdown feature set available in their best-of-breed IDE, however useRs can integrate markdown into their own toolchain of choice. Before getting into what the package can do, let me first describe the variant of Markdown supported by the package.
R Flavored Markdown, or RFM for short (not RTFM 😉
R Flavored Markdown is a plain-text formatting syntax for creating documents that can be rendered to HTML. In fact it’s like HTML, but simpler. R Flavored Markdown is a variant of original Markdown with a few additional features:
Github Flavored Markdown (GFM) which supports source code blocks,
Sundown Markdown which implements GFM but contains additional extensions like support for tables and automatic substitution for typographical characters, and
Embedded Math Equations with MathJax (think latex).
Here’s an example RFM document briefly describing the normal distribution functions of R (taken from the R help page for rnom)
The markdown package
The markdown package renders RFM into HTML via the markdownToHTML function:
markdownToHTML can accept input from either a file or a text object, and the HTML can either be written to a file (as shown above) or returned as a string. This should provide full flexibility for integrating markdown into various toolchains and computing scenarios.
Other features of the markdown package include:
smartypants function for rendering ASCII markup to HTML entities,
exported C API from the Sundown library for creating and calling new renderers using the renderMarkdown function, and
uploading of HTML files to RPubs, a soon-to-be-announced service from RStudio.