bookdown::render_book renders "multiple R Markdown files under the current working directory into a book". TODO: it seems this restriction will be lifted in the next bookdown release so let's see when it is out and adjust here as necessary That is, IMHO, unfortunate. In particular, when the book is not in the root of your project, you would have to mess with setwd() or the like and {here} won't help you either. This function works around this issue by leveraging xfun::in_dir to run bookdown::render_book in the input_dir of your choice. Then we do not have to deal ourselves with setwd() and changing it back.

bookme(
  input_dir,
  input_files = "*",
  output_dir = NULL,
  output_format = NULL,
  preview = FALSE
)

Arguments

input_dir

the main directory of the book

input_files

character vector with input files, in case you do not want to render them all (the default)

output_dir

The output directory. If NULL, a field named output_dir in the configuration file _bookdown.yml will be used (possibly not specified, either, in which case a directory name _book will be used).

output_format

as in bookdown::render_book

preview

Whether to render and preview the input files specified by the input argument. Previewing a certain chapter may save compilation time as you actively work on this chapter, but the output may not be accurate (e.g. cross-references to other chapters will not work).

Value

character vector with the path to the output

Details

In addition, the function calls base::shell to try and open the book in the default viewer for the output

Examples

if (FALSE) {
bookme("report")
}