This is a helper function to fuse() .Rmd files and convert all their
Markdown output to a single output file, which is similar to
bookdown::render_book(), but one major differences is that all HTML output
is written to one file, instead of one HTML file per chapter.
Usage
fuse_book(input = ".", output = NULL, envir = parent.frame())Arguments
- input
A directory or a vector of file paths. By default, all
.Rmd/.mdfiles under the current working directory are used as the input, except for filenames that start with.or_(e.g.,_foo.Rmd), or.mdfiles with the same base names as.Rmdfiles (e.g.,bar.mdwill not be used ifbar.Rmdexists). For a directoryinput, the file search will be recursive ifinputends with a slash (i.e., sub-directories will also be searched). If a file namedindex.Rmdorindex.mdexists, it will always be treated as the first input file. Input files can also be specified in the config file_litedown.yml(in theinputfield underbook).- output
An output file path or a filename extension (e.g.,
.html,.tex,.xml,.man,.markdown, or.txt). In the latter case, the output file path will use the extension on the same base filename as the input file if theinputis a file. Ifoutputis not character (e.g.,NA), the results will be returned as a character vector instead of being written to a file. IfoutputisNULLor an extension, and the input is a file path, the output file path will have the same base name as the input file, with an extension corresponding to the output format. The output format is retrieved from the first value in theoutputfield of the YAML metadata of theinput(e.g.,htmlwill generate HTML output). Theoutputargument can also take an output format name (possible values arehtml,latex,xml,man,commonmark, andtext). If no output format is detected or provided, the default is HTML.- envir
An environment in which the code is to be evaluated. It can be accessed via
fuse_env()insidefuse().
Details
If the output format needs to be customized, the settings should be written
in the config file _litedown.yml, e.g.,
In addition, you can configure the book via the book field, e.g.,
---
book:
new_session: true
subdir: false
pattern: "[.]R?md$"
chapter_before: "Information before a chapter."
chapter_after: "This chapter was generated from `$input$`."
---The option new_session specifies whether to render each input file in the
current R session or a separate new R session; chapter_before and
chapter_after specify text to be added to the beginning and end of each
file, respectively, which accepts some variables (e.g., $input$ is the
current input file path).