mark {markdown} | R Documentation |
Render Markdown to an output format via the commonmark package. The
function mark_html()
is a shorthand of mark(format = 'html')
,
and mark_latex()
is a shorthand of mark(format = 'latex')
.
mark( file = NULL, output = NULL, text = NULL, format = c("html", "latex"), options = NULL, template = FALSE, meta = list() ) mark_html(..., template = TRUE) mark_latex(..., template = TRUE)
file |
Path to an input file. If not provided, it is presumed that the
|
output |
Output file path. If not character, the results will be returned as a character vector. |
text |
A character vector of the Markdown text. By default, it is read
from |
format |
An output format supported by commonmark, e.g.,
|
options |
Options to be passed to the renderer. See
|
template |
Path to a template file. The default value is
|
meta |
A named list of metadata. Elements in the metadata will be used
to fill out the template by their names and values, e.g., |
... |
Arguments to be passed to |
Supported variables in metadata for both HTML and HTML templates (the string
FORMAT
below is the output format name, i.e., html
or
latex
):
header-includes
, include-before
,
include-after
Either a vector of code (HTML/LaTeX) or a code file to
be included in the header, before the body, or after the body of the output.
For header-include
, the default value is taken from
getOption('markdown.FORMAT.header')
if not provided in meta
.
title
The document title.
Variables for the HTML template:
css
A vector of CSS code or files to be included in the output.
The default value is getOption('markdown.html.css',
markdown:::pkg_file('resources', 'default.css'))
, i.e., it can be set via
the global option markdown.html.css
.
highlight
JavaScript code for syntax-highlighting code blocks. By default, the highlight.js library is used.
js
A vector of JavaScript code or JavaScript files to be included in the output.
math
JavaScript code for rendering LaTeX math. By default, MathJax is used.
Variables for the LaTeX template:
classoption
A string containing options for the document class.
documentclass
The document class (by default,
'article'
).
Note that you can use either underscores or hyphens in the variable names.
Underscores will be normalized to hyphens internally, e.g.,
header_includes
will be converted to header-includes
. This
means if you use a custom template, you must use hyphens instead of
underscores as separators in variable names in the template.
Invisible NULL
when output is to a file, otherwise a character
vector of the rendered output.
The spec of GitHub Flavored Markdown: https://github.github.com/gfm/
library(markdown) mark(c("Hello _World_!", "", "Welcome to **markdown**.")) # a few corner cases mark(character(0)) mark("") # if input looks like file but should be treated as text, use I() mark(I("This is *not* a file.md")) # that's equivalent to mark(text = "This is *not* a file.md") mark_html("Hello _World_!", options = "-standalone") # write HTML to an output file mark_html("_Hello_, **World**!", output = tempfile()) mark_latex("Hello _World_!", template = FALSE)