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.
fuse_book(input = ".", output = NULL, envir = parent.frame())
An output file path or the output content, depending on the output
argument.
A directory or a vector of file paths. By default, all
.Rmd
/.md
files under the current working directory are used as the
input, except for filenames that start with .
or _
(e.g., _foo.Rmd
),
or .md
files with the same base names as .Rmd
files (e.g., bar.md
will not be used if bar.Rmd
exists). For a directory input
, the file
search will be recursive if input
ends with a slash (i.e.,
sub-directories will also be searched). If a file named index.Rmd
or
index.md
exists, it will always be treated as the first input file. Input
files can also be specified in the config file _litedown.yml
(in the
input
field under book
).
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 the input
is a file. If output
is not character (e.g.,
NA
), the results will be returned as a character vector instead of being
written to a file. If output
is NULL
or 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 the output
field of the YAML
metadata of the input
(e.g., html
will generate HTML
output). The output
argument can also take an output format name
(possible values are html
, latex
, xml
, man
, commonmark
, and
text
). If no output format is detected or provided, the default is HTML.
An environment in which the code is to be evaluated. It can be
accessed via fuse_env()
inside fuse()
.
If the output format needs to be customized, the settings should be written
in the config file _litedown.yml
, e.g.,
---
output:
html:
options:
toc:
depth: 4
latex:
meta:
documentclass: "book"
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).