| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/site.R |
| 3 |
\name{fuse_book} |
| 4 |
\alias{fuse_book} |
| 5 |
\title{Fuse multiple R Markdown documents to a single output file} |
| 6 |
\usage{ |
| 7 |
fuse_book(input = ".", output = NULL, envir = parent.frame()) |
| 8 |
} |
| 9 |
\arguments{ |
| 10 |
\item{input}{A directory or a vector of file paths. By default, all |
| 11 |
\code{.Rmd}/\code{.md} files under the current working directory are used as the |
| 12 |
input, except for filenames that start with \code{.} or \verb{_} (e.g., \verb{_foo.Rmd}), |
| 13 |
or \code{.md} files with the same base names as \code{.Rmd} files (e.g., \code{bar.md} |
| 14 |
will not be used if \code{bar.Rmd} exists). For a directory \code{input}, the file |
| 15 |
search will be recursive if \code{input} ends with a slash (i.e., |
| 16 |
sub-directories will also be searched). If a file named \code{index.Rmd} or |
| 17 |
\code{index.md} exists, it will always be treated as the first input file. Input |
| 18 |
files can also be specified in the config file \verb{_litedown.yml} (in the |
| 19 |
\code{input} field under \code{book}).} |
| 20 |
|
| 21 |
\item{output}{An output file path or a filename extension (e.g., \code{.html}, |
| 22 |
\code{.tex}, \code{.xml}, \code{.man}, \code{.markdown}, or \code{.txt}). In the latter case, the |
| 23 |
output file path will use the extension on the same base filename as the |
| 24 |
input file if the \code{input} is a file. If \code{output} is not character (e.g., |
| 25 |
\code{NA}), the results will be returned as a character vector instead of being |
| 26 |
written to a file. If \code{output} is \code{NULL} or an extension, and the input is |
| 27 |
a file path, the output file path will have the same base name as the input |
| 28 |
file, with an extension corresponding to the output format. The output |
| 29 |
format is retrieved from the first value in the \code{output} field of the YAML |
| 30 |
metadata of the \code{input} (e.g., \code{html} will generate HTML output). The |
| 31 |
\code{output} argument can also take an output format name (possible values are |
| 32 |
\code{html}, \code{latex}, \code{xml}, \code{man}, \code{commonmark}, and \code{text}). If no output |
| 33 |
format is detected or provided, the default is HTML.} |
| 34 |
|
| 35 |
\item{envir}{An environment in which the code is to be evaluated. It can be |
| 36 |
accessed via \code{\link[=fuse_env]{fuse_env()}} inside \code{\link[=fuse]{fuse()}}.} |
| 37 |
} |
| 38 |
\value{ |
| 39 |
An output file path or the output content, depending on the \code{output} |
| 40 |
argument. |
| 41 |
} |
| 42 |
\description{ |
| 43 |
This is a helper function to \code{\link[=fuse]{fuse()}} \code{.Rmd} files and convert all their |
| 44 |
Markdown output to a single output file, which is similar to |
| 45 |
\code{bookdown::render_book()}, but one major differences is that all HTML output |
| 46 |
is written to one file, instead of one HTML file per chapter. |
| 47 |
} |
| 48 |
\details{ |
| 49 |
If the output format needs to be customized, the settings should be written |
| 50 |
in the config file \verb{_litedown.yml}, e.g., |
| 51 |
|
| 52 |
\if{html}{\out{<div class="sourceCode yaml">}}\preformatted{--- |
| 53 |
output: |
| 54 |
html: |
| 55 |
options: |
| 56 |
toc: |
| 57 |
depth: 4 |
| 58 |
latex: |
| 59 |
meta: |
| 60 |
documentclass: "book" |
| 61 |
}\if{html}{\out{</div>}} |
| 62 |
|
| 63 |
In addition, you can configure the book via the \code{book} field, e.g., |
| 64 |
|
| 65 |
\if{html}{\out{<div class="sourceCode yaml">}}\preformatted{--- |
| 66 |
book: |
| 67 |
new_session: true |
| 68 |
subdir: false |
| 69 |
pattern: "[.]R?md$" |
| 70 |
chapter_before: "Information before a chapter." |
| 71 |
chapter_after: "This chapter was generated from `$input$`." |
| 72 |
--- |
| 73 |
}\if{html}{\out{</div>}} |
| 74 |
|
| 75 |
The option \code{new_session} specifies whether to render each input file in the |
| 76 |
current R session or a separate new R session; \code{chapter_before} and |
| 77 |
\code{chapter_after} specify text to be added to the beginning and end of each |
| 78 |
file, respectively, which accepts some variables (e.g., \verb{$input$} is the |
| 79 |
current input file path). |
| 80 |
} |