diff --git a/NEWS.md b/NEWS.md index a638acce0..16af2ebd5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# CHANGES IN bookdown VERSION 0.37 + +- Custom config files passed to the `config_file` argument of `render_book()` are no longer temporarily renamed to `_bookdown.yml` (thanks, @debruine, #1307). + # CHANGES IN bookdown VERSION 0.36 - Fix an issue with parsing resources from raw HTML code (thanks, @lennylin, https://community.rstudio.com/t/bookdown-image-with-a-weblink/172542) diff --git a/R/render.R b/R/render.R index 77990a687..5adede7f5 100644 --- a/R/render.R +++ b/R/render.R @@ -104,17 +104,8 @@ render_book = function( "versions of bookdown." ) - if (config_file != '_bookdown.yml') { - unlink(tmp_config <- tempfile('_bookdown_', '.', '.yml')) - if (file.exists('_bookdown.yml')) file.rename('_bookdown.yml', tmp_config) - file.rename(config_file, '_bookdown.yml') - on.exit({ - file.rename('_bookdown.yml', config_file) - if (file.exists(tmp_config)) file.rename(tmp_config, '_bookdown.yml') - }, add = TRUE) - } - on.exit(opts$restore(), add = TRUE) + opts$set(config_file = config_file) config = load_config() # configurations in _bookdown.yml output_dir = output_dirname(output_dir, config) on.exit(xfun::del_empty_dir(output_dir), add = TRUE) diff --git a/R/utils.R b/R/utils.R index 9599b43a9..10ebebd43 100644 --- a/R/utils.R +++ b/R/utils.R @@ -69,10 +69,11 @@ get_base_format = function(format, options = list()) { do.call(format, options) } -load_config = function() { - if (length(opts$get('config')) == 0 && file.exists('_bookdown.yml')) { +load_config = function(config_file = '_bookdown.yml') { + config_file = opts$get('config_file') %n% config_file + if (length(opts$get('config')) == 0 && file.exists(config_file)) { # store the book config - opts$set(config = rmarkdown:::yaml_load_file('_bookdown.yml')) + opts$set(config = rmarkdown:::yaml_load_file(config_file)) } opts$get('config') }