Skip to content

Commit

Permalink
Add split_bib to bs4_book (rstudio#1185)
Browse files Browse the repository at this point in the history
`split_bib = FALSE` by default for this format though as before.

Co-authored-by: Christophe Dervieux <[email protected]>
  • Loading branch information
shirdekel and cderv authored Jul 23, 2021
1 parent b3f11ba commit 6ae8900
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: bookdown
Type: Package
Title: Authoring Books and Technical Documents with R Markdown
Version: 0.22.14
Version: 0.22.15
Authors@R: c(
person("Yihui", "Xie", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-0645-5666")),
person("JJ", "Allaire", role = "ctb"),
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# CHANGES IN bookdown VERSION 0.23

- `bs4_book(splib_bib = TRUE)` can now be specified to have the same effect as in `gitbook()`. References will be shown at the end of each chapter and not only at the end of the book. This is useful with `bs4_book()` when a citation style not supporting footnotes is used because in that case, references are not shown inline in popups (thanks, @shirdekel, #1185).

- For HTML book formats, a default `404.html` page will now be created if none exists already. This page can be customized by adding a `_404.md` or `_404.Rmd` file which will be rendered to HTML and inserted in the book. Most web serving platforms (e.g. Netlify, GH Pages, etc.) will use this file named `404.html` in the root as a custom error page. Otherwise, like browsers do, a default 404 page is shown. For context, a 404 error indicates that the file can’t be found, and it happens when a browser can’t find a requested web page. This could happen with your online book if you shared a link to a section but change the name of this section leading to a change in url (#1035).

- In `bs4_book()`, improvement regarding copy button:
Expand Down
13 changes: 8 additions & 5 deletions R/bs4_book.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#' @param repo Either link to repository where book is hosted, used to generate
#' view source and edit buttons or a list with repository `base` link, default
#' `branch`, `subdir` and `icon` (see "Specifying the repository").
#' @param lib_dir,pandoc_args,extra_dependencies,... Passed on to
#' @param lib_dir,pandoc_args,extra_dependencies,split_bib,... Passed on to
#' [rmarkdown::html_document()].
#'
#' @section Specifying the repository:
Expand Down Expand Up @@ -147,7 +147,8 @@ bs4_book <- function(theme = bs4_book_theme(),
...,
lib_dir = "libs",
pandoc_args = NULL,
extra_dependencies = NULL) {
extra_dependencies = NULL,
split_bib = FALSE) {
check_packages(bs4_book_deps())
bs4_check_dots(...)

Expand Down Expand Up @@ -175,7 +176,8 @@ bs4_book <- function(theme = bs4_book_theme(),
output <- post(metadata, input, output, clean, verbose)
}

output2 <- bs4_book_build(output, repo = repo, lib_dir = lib_dir)
output2 <- bs4_book_build(output, repo = repo, lib_dir = lib_dir,
split_bib = split_bib)

if (clean && file.exists(output) && !same_path(output, output2)) {
file.remove(output)
Expand All @@ -200,7 +202,8 @@ bs4_book_theme <- function(primary = "#0068D9", ...) {
bs4_book_build <- function(output = "bookdown.html",
repo = NULL,
lib_dir = "libs",
output_dir = opts$get("output_dir")) {
output_dir = opts$get("output_dir"),
split_bib = split_bib) {
move_files_html(output, lib_dir)

rmd_index <- new.env(parent = emptyenv())
Expand All @@ -209,7 +212,7 @@ bs4_book_build <- function(output = "bookdown.html",
build = function(...) bs4_book_page(..., rmd_index = rmd_index),
number_sections = TRUE,
split_by = "chapter",
split_bib = FALSE
split_bib = split_bib
)

move_files_html(output2, lib_dir)
Expand Down
5 changes: 3 additions & 2 deletions man/bs4_book.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6ae8900

Please sign in to comment.