fuse | R Documentation |
The function fuse()
extracts and runs code from code chunks
and inline code expressions in R Markdown, and interweaves the results with
the rest of text in the input, which is similar to what knitr::knit()
and
rmarkdown::render()
do. It also works on R scripts in a way similar to
knitr::spin()
. The function fiss()
extracts code from the input, and is
similar to knitr::purl()
.
The function mark()
renders Markdown to an output format via the
commonmark package.
fuse(input, output = NULL, text = NULL, envir = parent.frame(), quiet = FALSE)
fiss(input, output = ".R", text = NULL)
mark(input, output = NULL, text = NULL, options = NULL, meta = list())
input |
A character vector to provide the input file path or text. If
not provided, the |
output |
An output file path or a filename extension (e.g., |
text |
A character vector as the text input. By default, it is read from
the |
envir |
An environment in which the code is to be evaluated. It can be
accessed via |
quiet |
If |
options |
Options to be passed to the renderer. See |
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., |
The output file path if output is written to a file, otherwise a
character vector of the rendered output (wrapped in xfun::raw_string()
for clearer printing).
sieve()
, for the syntax of R scripts to be passed to fuse()
.
The spec of GitHub Flavored Markdown: https://github.github.com/gfm/
library(litedown)
doc = c("```{r}", "1 + 1", "```", "", "$\\pi$ = `{r} pi`.")
fuse(doc)
fuse(doc, ".tex")
fiss(doc)
mark(c("Hello _World_!", "", "Welcome to **litedown**."))
# if input appears to be a file path 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")
# output to a file
(mark("_Hello_, **World**!", output = tempfile()))
# convert to other formats
mark("Hello _World_!", ".tex")
mark("Hello _**`World`**_!", "xml")
mark("Hello _**`World`**_!", "text")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.