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
)

Arguments

path

path to Rmd file

script

optional spoken script, otherwise taken from the HTML comments

capture_method

Either "vectorized" or "iterative". The vectorized mode is faster though it can cause screens to repeat. If making a video from an rmarkdown::ioslides_presentation you should use "iterative".

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

Value

The output of make_ari_document

Examples

# \donttest{ 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 } }
#> #> #> processing file: example.Rmd
#> | | | 0% | |....................... | 33% #> ordinary text without R code #> #> | |............................................... | 67% #> label: unnamed-chunk-1 (with options) #> List of 1 #> $ eval: logi FALSE #> #> | |......................................................................| 100% #> ordinary text without R code #> #>
#> output file: example.knit.md
#> /usr/local/bin/pandoc +RTS -K512m -RTS example.utf8.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output /var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmptXiJUn/file139276526496d.html --lua-filter /Users/johnmuschelli/Library/R/4.0/library/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /Users/johnmuschelli/Library/R/4.0/library/rmarkdown/rmarkdown/lua/latex-div.lua --self-contained --variable transition=0.4 --template /Users/johnmuschelli/Library/R/4.0/library/rmarkdown/rmd/ioslides/default.html --include-in-header /var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmptXiJUn/rmarkdown-str13927202255cb.html --mathjax --variable 'mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' #> /usr/local/bin/pandoc +RTS -K512m -RTS example.utf8.md --to ioslides_presentation.lua --from markdown+autolink_bare_uris+tex_math_single_backslash --output /var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmptXiJUn/ioslides-output139272e2e92e8.html --slide-level 2
#> #> Output created: /var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmptXiJUn/file139276526496d.html
#> Parsing HTML comments for script
#> Rendering Rmd to HTML
#> #> #> processing file: example.Rmd
#> | | | 0% | |....................... | 33% #> ordinary text without R code #> #> | |............................................... | 67% #> label: unnamed-chunk-1 (with options) #> List of 1 #> $ eval: logi FALSE #> #> | |......................................................................| 100% #> ordinary text without R code #> #>
#> output file: example.knit.md
#> /usr/local/bin/pandoc +RTS -K512m -RTS example.utf8.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output /var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmptXiJUn/file1392716eb99c9.html --lua-filter /Users/johnmuschelli/Library/R/4.0/library/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /Users/johnmuschelli/Library/R/4.0/library/rmarkdown/rmarkdown/lua/latex-div.lua --self-contained --variable transition=0.4 --template /Users/johnmuschelli/Library/R/4.0/library/rmarkdown/rmd/ioslides/default.html --include-in-header /var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmptXiJUn/rmarkdown-str1392715ad1fe5.html --mathjax --variable 'mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' #> /usr/local/bin/pandoc +RTS -K512m -RTS example.utf8.md --to ioslides_presentation.lua --from markdown+autolink_bare_uris+tex_math_single_backslash --output /var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmptXiJUn/ioslides-output139271908fe81.html --slide-level 2
#> #> Output created: /var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmptXiJUn/file1392716eb99c9.html
#> Using the browser "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
#> Trying to find headless Chrome in 20 attempts
#> Headless Chrome found at attempt 2
#> Browser version: HeadlessChrome/91.0.4472.106
#> Serving the directory /private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmptXiJUn at http://127.0.0.1:3196/file1392716eb99c9.html
#> Closing websocket connection
#> Closing browser
#> Cleaning browser working directory
#> Closing local webserver
#> Converting page 1 to /var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmptXiJUn/file139271c74cd10.png... done! #> Converting page 2 to /var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmptXiJUn/file1392724c012e4.png... done! #> Converting page 3 to /var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmptXiJUn/file139272c86f50c.png... done! #> Converting page 4 to /var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmptXiJUn/file139273e184995.png... done! #> Converting page 5 to /var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmptXiJUn/file139275041fdaa.png... done!
#> Making output_file directories
#> [1] "/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmptXiJUn/file139273842e408.md"
# } # \donttest{ # 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") } }
#> #> #> processing file: file139272f88e613.Rmd
#> | | | 0% | |.............. | 20% #> ordinary text without R code #> #> | |............................ | 40% #> label: setup (with options) #> List of 1 #> $ include: logi FALSE #> #> | |.......................................... | 60% #> ordinary text without R code #> #> | |........................................................ | 80% #> label: unnamed-chunk-1 (with options) #> List of 1 #> $ fig.height: num 4 #>
#> | |......................................................................| 100% #> ordinary text without R code #> #>
#> output file: file139272f88e613.knit.md
#> /usr/local/bin/pandoc +RTS -K512m -RTS file139272f88e613.utf8.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output /var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmptXiJUn/file1392744b901c6.html --lua-filter /Users/johnmuschelli/Library/R/4.0/library/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /Users/johnmuschelli/Library/R/4.0/library/rmarkdown/rmarkdown/lua/latex-div.lua -V 'mathjax-url=https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-MML-AM_CHTML' -V 'title-slide-class=center, middle, inverse, title-slide' --standalone --section-divs --template /Users/johnmuschelli/Library/R/4.0/library/xaringan/rmarkdown/templates/xaringan/resources/default.html --no-highlight --include-in-header /var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmptXiJUn/rmarkdown-str1392739ba6ad6.html --include-before-body /var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmptXiJUn/xaringan1392711fac93.md --include-after-body /var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmptXiJUn/xaringan139274e239169.js --variable title-slide=true --variable math=true
#> #> Output created: /var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmptXiJUn/file1392744b901c6.html
#> Error in xaringan::decktape(rendered_file, pdf_file, docker = FALSE): Failed to convert /var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmptXiJUn/file1392744b901c6.html to PDF
# }