Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

renderMarkdown

Render markdown to an HTML fragment


Description

renderMarkdown transforms the markdown text provided by the user in either the file or text variable. The transformation is either written to the output file or returned to the user. The default rendering target is "HTML".

Usage

renderMarkdown(file, output = NULL, text = NULL, renderer = "HTML", 
    renderer.options = NULL, extensions = getOption("markdown.extensions"), 
    encoding = "UTF-8")

Arguments

file

a character string giving the pathname of the file to read from. If it is omitted from the argument list, then it is presumed that the text argument will be used instead.

output

a character string giving the pathname of the file to write to. If it is omitted (NULL), then it is presumed that the user expects the results returned as a character vector.

text

a character vector containing the markdown text to transform (each element of this vector is treated as a line in a file).

renderer

the name of the renderer that will be used to transform the file or text.

renderer.options

options that are passed to the renderer. For HTML renderer options see markdownHTMLOptions.

extensions

options that are passed to the markdown engine. See markdownExtensions.

encoding

ignored (always assumes the file is encoded in UTF-8).

Details

markdown uses (and ships with) the popular Sundown library provided by GitHub. C stubs are available to implement new renderers.

Value

renderMarkdown returns NULL invisibly when output is to a file, and either character (with the UTF-8 encoding) or raw vector depending on the renderer output type.

See Also

For a description of the original markdown version: http://daringfireball.net/projects/markdown/

The original Sundown library on github: https://github.com/vmg/sundown

C stubs for writing new renders are in inst/include/markdown_rstubs.[ch].

Examples

(renderMarkdown(text = "Hello World!"))
# a few corner cases
(renderMarkdown(text = character(0)))
(renderMarkdown(text = ""))

markdown

Render Markdown with the C Library 'Sundown'

v1.1
GPL-2
Authors
JJ Allaire [aut], Jeffrey Horner [aut], Yihui Xie [aut, cre] (<https://orcid.org/0000-0003-0645-5666>), Henrik Bengtsson [ctb], Jim Hester [ctb], Yixuan Qiu [ctb], Kohske Takahashi [ctb], Adam November [ctb], Nacho Caballero [ctb], Jeroen Ooms [ctb], Thomas Leeper [ctb], Joe Cheng [ctb], Andrzej Oles [ctb], Vicent Marti [aut, cph] (The Sundown library), Natacha Porte [aut, cph] (The Sundown library), RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.