Render markdown to HTML
markdownToHTML transforms the markdown text provided by the
user in either the
text variable. The HTML
transformation is either written to the
output file or returned to the
user as a
markdownToHTML(file, output = NULL, text = NULL, options = getOption("markdown.HTML.options"), extensions = getOption("markdown.extensions"), title = "", stylesheet = getOption("markdown.HTML.stylesheet"), header = getOption("markdown.HTML.header"), template = getOption("markdown.HTML.template"), fragment.only = FALSE, encoding = getOption("encoding"))
- 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
textargument will be used instead.
- 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
- a character vector containing the markdown text to transform (each element of this vector is treated as a line in a file).
- options that are passed to the renderer. see
- options that are passed to the markdown engine. See
- The HTML title.
- either valid CSS or a file containing CSS. will be included in the output.
- either valid HTML or a file containing HTML will be included in the header of the output.
- an HTML file used as template.
- the encoding of the input file; see
Three notable HTML options have been added to support collaborative reproducible research. They are as follows:
- Rcode blocks enclosed between
```rand ```will automatically be syntax highlighted.
- Any local images linked using the tag will be base64 encoded and included in the output HTML.
See the DETAILS section below and
markdownHTMLOptions for more
There are two basic modes to
markdownToHTML determined by the value of
markdownToHTML creates well-formed stand-alone HTML
pages complete with HTML header, title, and body tags. The default template
used for this mode may be found here:
system.file('resources', 'markdown.html', package = 'markdown')
markdownToHTML will automatically determine whether or not
mathjax and R code highlighting are needed and will include the appropriate
'highlight_code' options (see
markdownHTMLOptions for more details).
fragment.only is TRUE, nothing extra is added.
NULLwhen output is to a file, and a character vector otherwise.
(markdownToHTML(text = "Hello World!", fragment.only = TRUE)) (markdownToHTML(file = NULL, text = "_text_ will override _file_", fragment.only = TRUE)) # write HTML to an output file markdownToHTML(text = "_Hello_, **World**!", output = "test.html")