Skip to content

Commit

Permalink
Change calls to knitr:::%n% to %||% (#1480)
Browse files Browse the repository at this point in the history
Co-authored-by: Yihui Xie <[email protected]>
  • Loading branch information
cgrandin and yihui authored Nov 13, 2024
1 parent 9dca1f9 commit bd78cf8
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion R/bs4_book.R
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ tweak_navbar <- function(html, toc, active = "", rmd_index = NULL, repo = NULL)
}

if (!is.null(repo$base)) {
icon <- repo$icon %n%
icon <- repo$icon %||%
ifelse(grepl("github\\.com", repo$base), "fab fa-github", "fab fa-gitlab")
template_link_icon(html, ".//a[@id='book-repo']", icon)
template_link_icon(html, ".//a[@id='book-source']", icon)
Expand Down
2 changes: 1 addition & 1 deletion R/html.R
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ add_chapter_prefix = function(content) {
add_chapter_prefix_one = function(content, type = c('chapter', 'appendix')) {
config = load_config()
field = paste0(type, '_name')
chapter_name = config[[field]] %n% ui_language(field)
chapter_name = config[[field]] %||% ui_language(field)
if (is.null(chapter_name) || identical(chapter_name, '')) return(content)
chapter_fun = if (is.character(chapter_name)) {
function(i) switch(
Expand Down
2 changes: 1 addition & 1 deletion R/skeleton.R
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ skeleton_get_dir = function(...) {

skeleton_get_files = function(subdir = NULL, relative = TRUE) {
resources = skeleton_get_dir()
subdir = file.path(resources, subdir %n% "")
subdir = file.path(resources, subdir %||% "")
if (!dir.exists(subdir)) return(NULL)
files = list.files(subdir, recursive = TRUE, include.dirs = FALSE, full.names = TRUE)
if (relative) xfun::relative_path(files, resources) else files
Expand Down
4 changes: 2 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ get_base_format = function(format, options = list()) {
}

load_config = function(config_file = '_bookdown.yml') {
config_file = opts$get('config_file') %n% config_file
config_file = opts$get('config_file') %||% config_file
if (length(opts$get('config')) == 0 && file.exists(config_file)) {
# store the book config
opts$set(config = rmarkdown:::yaml_load_file(config_file))
Expand Down Expand Up @@ -489,7 +489,7 @@ verify_rstudio_version = function() {

str_trim = function(x) gsub('^\\s+|\\s+$', '', x)

`%n%` = knitr:::`%n%`
if (getRversion() < '4.4.0') `%||%` = function(x, y) if (is.null(x)) y else x

output_md = function() getOption('bookdown.output.markdown', FALSE)

Expand Down

0 comments on commit bd78cf8

Please sign in to comment.