Skip to content
High Performance CommonMark and Github Markdown Rendering in R
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
R Bump Apr 27, 2018
src Add a few tests Dec 1, 2018
tests Add test for embedded images Dec 1, 2018
.Rbuildignore Update readme Dec 13, 2016
.gitignore Add wrapper markdown_text() Aug 31, 2017
.travis.yml Update Travis Apr 27, 2018
DESCRIPTION Suggest xml2 for tests Dec 1, 2018
appveyor.yml Enable CI Apr 16, 2016
commonmark.Rproj first commit May 24, 2015
readme.Rmd MASS rename Mar 14, 2017 MASS rename Mar 14, 2017


High Performance CommonMark and Github Markdown Rendering in R

Build Status AppVeyor Build Status Coverage Status CRAN_Status_Badge CRAN RStudio mirror downloads Github Stars

The CommonMark specification defines a rationalized version of markdown syntax. This package uses the 'cmark' reference implementation for converting markdown text into various formats including html, latex and groff man. In addition it exposes the markdown parse tree in xml format. The latest version of this package also adds support for Github extensions including tables, autolinks and strikethrough text.


About the R package:

Other resources:

Basic Markdown

md <- "## Test
An *example* text for the `commonmark` package."

# Convert to Latex

An \emph{example} text for the \texttt{commonmark} package.
# Convert to HTML
<p>An <em>example</em> text for the <code>commonmark</code> package.</p>
# Convert to 'groff' man 
An \f[I]example\f[] text for the \f[C]commonmark\f[] package.
# Convert back to (normalized) markdown
## Test

An *example* text for the `commonmark` package.
# The markdown parse tree
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE document SYSTEM "CommonMark.dtd">
<document xmlns="">
  <heading level="2">
    <text>An </text>
    <text> text for the </text>
    <text> package.</text>

Github Extensions

Commonmark includes several 'extensions' to enable features which are not (yet) part of the official specification. The current version of the commonmark R package offers 4 such extensions:

  • table support rendering of tables
  • strikethough via ~sometext~ syntax
  • autolink automatically turn URLs into hyperlinks
  • tagfilter blacklist html tags: title textarea style xmp iframe noembed noframes script plaintext.

These extensions were added by Github to support GitHub Flavored Markdown.

table <- '
aaa | bbb | ccc | ddd | eee
:-- | --- | :-: | --- | --:
fff | ggg | hhh | iii | jjj'

cat(markdown_latex(table, extensions = TRUE))
aaa & bbb & ccc & ddd & eee \\
fff & ggg & hhh & iii & jjj \\
cat(markdown_html(table, extensions = TRUE))
<th align="left">aaa</th>
<th align="center">ccc</th>
<th align="right">eee</th>
<td align="left">fff</td>
<td align="center">hhh</td>
<td align="right">jjj</td>
You can’t perform that action at this time.