Creates accessible html documents using R markdown's
html_document argument to
render. Zip archives of the html files may be
created.
Arguments
- x
A character vector containing the names (no extension) of the
.Rmdfiles to convert if they are in the current working directory, or paths to the files, either absolute or relative to the current working directory, e.g.,DIRECTORY/file1. The.htmlfiles are created in the same directory as their respective.Rmdfile. Ifxis missing then an html file is created from each of the.Rmdfiles in the current working directory.- zip
A logical scalar or character vector indicating whether html files should be put into a zip archive. If
zip = FALSEthen no zip archive is created. Otherwise, an archive is created in each unique directory involved inx. Ifzip = TRUEeach archive of html files is namedaccessr_html.zip. Ifzipis a character vector of zip file names (no extension) then these names are used to name the zip archives. The names are recycled to the length of the number of unique directories, if necessary.A logical scalar. If
pdf = TRUEthen each html file is printed to a PDF file usingchrome_print. Google Chrome (or an alternative browser specified inpdf_argsby thebrowserargument tochrome_print) must be installed prior to use of this option. An error message likeError in servr::random_port(NULL) : Cannot find an available TCP portmeans that therandom_portfunction in theservrpackage could not find an internet connection that Chrome considers secure. Perhaps you are using a coffee shop's wifi.- pdf_args
A list of arguments passed to
chrome_print.inputcannot be passed because it is set insidermd2html.- zip_pdf
As
zip, but relates to the creation of zip archives for any PDF files created. Ifzip_pdf = TRUEthen each archive is namedaccessr_html_pdf.zip.- add
A logical scalar that determines what happens if an output zip file already exists. If
add = TRUEthen files are added to the zip file and ifadd = FALSEthen the zip file is deleted and will only contain newly-created files.- quiet
Argument of the same name passed to
renderto determine what is printed during rendering from knitr.- rm_html
A logical scalar. If
rm_html = TRUEand a zip archive of html files is produced then the individual html files are deleted. Otherwise, they are not deleted.- rm_pdf
A logical scalar. If
rm_pdf = TRUEand a zip archive of pdf files is produced then the individual pdf files are deleted. Otherwise, they are not deleted.- ...
Additional arguments passed to
html_documentorrender.
Value
In addition to creating the html files, and perhaps zip files, a list containing the following (character vector) components is returned invisibly:
- files
(absolute) paths and file names of the files added to a zip file.
- zips
(relative) paths and names of all the zip files.
Details
Information such as title, author, lang etc in
the YAML header in the Rmd file are used but output is ignored.
The simplest setup is to have the .Rmd files in the current
working directory, in which case rmd2html() will create HTML documents
from all these Rmd files, the .Rmd files may be in different
directories.
The render function, with the argument
output_file = html_document
creates the html files.
See also
rmd2many, rmd2word,
rmd2ioslides, rmd2slidy for other output
formats.
Examples
# Create an HTML document from example.Rmd
got_hux <- requireNamespace("huxtable", quietly = TRUE)
got_flex <- requireNamespace("flextable", quietly = TRUE)
got_pandoc <- rmarkdown::pandoc_available("1.14")
got_all <- got_hux && got_flex && got_pandoc
# This example needs packages huxtable and flextable
if (got_all) {
ex_file <- system.file(package = "accessr", "examples", "example.Rmd")
file.copy(ex_file, tdir <- tempdir(check = TRUE), overwrite = TRUE)
ex_file <- list.files(tdir, pattern = "example.Rmd", full.names = TRUE)
ex_file <- sub(".Rmd", "", ex_file)
rmd2html(ex_file)
}