Description Usage Arguments Value Examples
Prepare customised bookdown from skeleton and template This function creates an Rstudio project in path, sets build type to "website", copies the content of book_skeleton at the root of the project, copies all files from the book template, modifies pre-defined variable book_title, author_name, creation_date, as well as any variable added by the user in replacements (index_title, index_content...), and inserts the content of index.txt in index.Rmd (here containing the user defined variables index_title and index_content).
1 2 3 4 5 6 7 8 9 | prepare_book(
path,
replacements = c(book_title = "My book", author_name = "Marion Louveaux",
creation_date = "`r Sys.Date()`", short_description =
"An example of book with {bookprep}.", index_title = "Context"),
skeleton = system.file("book_skeleton", package = "bookprep"),
template = system.file("book_template_example", package = "bookprep"),
pattern = "[.]Rmd$|[.]yml$|[.]md$"
)
|
path |
where to create the bookdown |
replacements |
a vector of correspondences between an input and an output. Input is fixed and corresponds to: book_title, author_name, creation_date, short_description and index_title |
skeleton |
path to directory containing bookdown skeleton |
template |
path to directory containing template files for chapters and index content |
pattern |
regex to identify files to prepare (by default, all Rmd, yml and md files) |
used for side effect: file creation in path
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # Create temporary directory for reproducible example
dir_tmp <- tempfile(pattern = "proj-")
dir.create(dir_tmp)
# browseURL(dir_tmp)
prepare_book(
path = dir_tmp,
template = system.file("book_template_example", package = "bookprep"),
replacements = c(
# replacements mandatory for the bookdown skeleton
"book_title" = "My book",
"author_name" = "Marion Louveaux",
"creation_date" = "`r Sys.Date()`",
"short_description" = "An example of book with {bookprep}.",
# replacement specific to my template that you can add if you want
"index_title" = "Context"
)
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.