Title: | High Performance CommonMark and Github Markdown Rendering in R |
---|---|
Description: | The CommonMark specification <https://github.github.com/gfm/> 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. Also includes opt-in support for GFM extensions including tables, autolinks, and strikethrough text. |
Authors: | Jeroen Ooms [aut, cre] , John MacFarlane [cph] (Author of cmark) |
Maintainer: | Jeroen Ooms <[email protected]> |
License: | BSD_2_clause + file LICENSE |
Version: | 1.9.3 |
Built: | 2024-11-11 06:30:44 UTC |
Source: | https://github.com/r-lib/commonmark |
Converts markdown text to several formats using John MacFarlane's cmark
reference implementation. Supported output formats include html
, latex
, groff man
, and normalized
"commonmark" markdown. In addition the markdown parse tree can be returned in xml format.
markdown_html( text, hardbreaks = FALSE, smart = FALSE, normalize = FALSE, sourcepos = FALSE, footnotes = FALSE, extensions = FALSE ) markdown_xml( text, hardbreaks = FALSE, smart = FALSE, normalize = FALSE, sourcepos = FALSE, footnotes = FALSE, extensions = FALSE ) markdown_man( text, hardbreaks = FALSE, smart = FALSE, normalize = FALSE, footnotes = FALSE, width = 0, extensions = FALSE ) markdown_commonmark( text, hardbreaks = FALSE, smart = FALSE, normalize = FALSE, footnotes = FALSE, width = 0, extensions = FALSE ) markdown_text( text, hardbreaks = FALSE, smart = FALSE, normalize = FALSE, footnotes = FALSE, width = 0, extensions = FALSE ) markdown_latex( text, hardbreaks = FALSE, smart = FALSE, normalize = FALSE, footnotes = FALSE, width = 0, extensions = FALSE )
markdown_html( text, hardbreaks = FALSE, smart = FALSE, normalize = FALSE, sourcepos = FALSE, footnotes = FALSE, extensions = FALSE ) markdown_xml( text, hardbreaks = FALSE, smart = FALSE, normalize = FALSE, sourcepos = FALSE, footnotes = FALSE, extensions = FALSE ) markdown_man( text, hardbreaks = FALSE, smart = FALSE, normalize = FALSE, footnotes = FALSE, width = 0, extensions = FALSE ) markdown_commonmark( text, hardbreaks = FALSE, smart = FALSE, normalize = FALSE, footnotes = FALSE, width = 0, extensions = FALSE ) markdown_text( text, hardbreaks = FALSE, smart = FALSE, normalize = FALSE, footnotes = FALSE, width = 0, extensions = FALSE ) markdown_latex( text, hardbreaks = FALSE, smart = FALSE, normalize = FALSE, footnotes = FALSE, width = 0, extensions = FALSE )
text |
Markdown text |
hardbreaks |
Treat newlines as hard line breaks. If this option is specified, hard wrapping is disabled
regardless of the value given with |
smart |
Use smart punctuation. See details. |
normalize |
Consolidate adjacent text nodes. |
sourcepos |
Include source position attribute in output. |
footnotes |
parse footnotes |
extensions |
Enables Github extensions. Can be |
width |
Specify wrap width (default 0 = nowrap). |
Support for extensions (including tables and autolink) is provided via the Github
fork of cmark. For now these are opt-in and have to be
enabled with the extensions
parameter. See also the manual page on extensions.
When smart punctuation is enabled, straight double and single quotes will be rendered as curly quotes,
depending on their position. Moreover --
will be rendered as – (en-dash), ---
will be
rendered as — (em-dash), and ...
will be rendered as ... (ellipses).
md <- readLines("https://raw.githubusercontent.com/yihui/knitr/master/NEWS.md") html <- markdown_html(md) xml <- markdown_xml(md) man <- markdown_man(md) tex <- markdown_latex(md) cm <- markdown_commonmark(md) text <- markdown_text(md)
md <- readLines("https://raw.githubusercontent.com/yihui/knitr/master/NEWS.md") html <- markdown_html(md) xml <- markdown_xml(md) man <- markdown_man(md) tex <- markdown_latex(md) cm <- markdown_commonmark(md) text <- markdown_text(md)
The Github fork of cmark supports several markdown extensions which provide features which are not (yet) in the official commonmark spec.
list_extensions()
list_extensions()
Currently the following extensions are supported:
table support rendering of tables: gfm-spec section 4.10
strikethrough via ~~sometext~~
syntax: gfm-spec section 6.5
autolink automatically turn URLs into hyperlinks: gfm-spec section 6.9
tagfilter blacklist html tags: title
textarea
style
xmp
iframe
noembed
noframes
script
plaintext
: gfm-spec section 6.11
tasklist turns certain list items into checkboxes: gfm-spec section 5.3
See the full spec for GitHub Flavored Markdown.
print(list_extensions())
print(list_extensions())