rmd_to_ari | R Documentation |
Convert a Rmd to an Ari Document
rmd_to_ari(
path,
script = NULL,
capture_method = c("iterative", "vectorized"),
capturer = c("chrome_print", "webshot", "decktape"),
capturer_args = list(),
...,
rendered_file = NULL,
verbose = TRUE
)
path |
path to Rmd file |
script |
optional spoken script, otherwise taken from the HTML comments |
capture_method |
Either |
capturer |
Methods for capturing the HTML slides |
capturer_args |
a list of arguments to pass to webshot::webshot or pagedown::chrome_print |
... |
additional arguments to pass to make_ari_document |
rendered_file |
the HTML output already from render |
verbose |
print diagnostic messages |
The output of make_ari_document
if (rmarkdown::pandoc_available("1.12.3")) {
path = system.file("extdata", "example.Rmd", package = "ariExtra")
tfile = tempfile(fileext = ".pdf")
out = try({
output_file = tempfile(fileext = ".html")
rmarkdown::render(path, output_file = output_file)
pagedown::chrome_print(output_file,
output = tfile)
}, silent = TRUE)
if (!inherits(out, "try-error")) {
res = rmd_to_ari(path, open = FALSE)
res$output_file
}
}
# xaringan example
if (requireNamespace("xaringan", quietly = TRUE)) {
path = system.file("examples", "lucy-demo.Rmd", package = "xaringan")
# get rid of ggplot2 dependency
x = readLines(path)
x = gsub("library\\(ggplot2\\)", "", x)
x = gsub("^\\s*ggplot.*", "", x)
x = gsub("^\\s*geom_bar.*", "barplot(table(mtcars$am))", x)
path = tempfile(fileext = ".Rmd")
writeLines(x, path)
rendered_file = tempfile(fileext = ".html")
required_pandoc <- "1.12.3"
have_pandoc_version = rmarkdown::pandoc_available(required_pandoc)
if (have_pandoc_version) {
rmarkdown::render(path,
output_format = xaringan::moon_reader(),
output_file = rendered_file)
} else {
rendered_file = system.file("extdata",
"lucy-demo-noggplot2.html",
package = "ariExtra")
}
script = c("this", "is", "one", "word", "per slide")
have_decktape = nzchar(Sys.which("decktape"))
if (have_decktape) {
pdf_file = tempfile(fileext = ".pdf")
xaringan::decktape(rendered_file, pdf_file, docker = FALSE)
res = pdf_to_ari(pdf_file, script = script, open = FALSE)
result = rmd_to_ari(path = path,
script = script,
rendered_file = rendered_file,
capturer = "decktape")
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.