Skip to content

Commit

Permalink
Replace stringr::str_split() with strsplit() (#2187, #1549)
Browse files Browse the repository at this point in the history
Co-authored-by: Yihui Xie <xie@yihui.name>
  • Loading branch information
rich-iannone and yihui committed Oct 19, 2022
1 parent 1ce8286 commit 67b973d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion R/pandoc.R
Expand Up @@ -122,7 +122,7 @@ pandoc_arg = function(x) {
nms = names(x)
if (any(grepl('\n', x))) {
# one argument used multiple times, e.g. --bibliography
x = stringr::str_split(x, '\n')
x = str_split(x, '\n')
nms = rep(nms, sapply(x, length))
x = unlist(x)
}
Expand Down
9 changes: 8 additions & 1 deletion R/utils.R
Expand Up @@ -74,7 +74,7 @@ color_def = function(col, variable = 'shadecolor') {
sc_split = function(string) {
if (is.call(string)) string = eval(string)
if (is.numeric(string) || length(string) != 1L) return(string)
trimws(stringr::str_split(string, ';|,')[[1]])
trimws(strsplit(string, ';|,')[[1]])
}

# extract LaTeX packages for tikzDevice
Expand Down Expand Up @@ -1078,3 +1078,10 @@ remove_urls = function(x) {

# repeat a string for n times
rep_str = function(x, n, sep = '') paste(rep(x, n), collapse = sep)

# patch strsplit() to split '' into '' instead of character(0)
str_split = function(x, split, ...) {
y = strsplit(x, split, ...)
y[x == ''] = list('')
y
}

0 comments on commit 67b973d

Please sign in to comment.