Skip to content

Commit

Permalink
vectorize the code to add . to suffix in fig_path() (#2373)
Browse files Browse the repository at this point in the history
Co-authored-by: Yihui Xie <xie@yihui.name>
  • Loading branch information
gaospecial and yihui authored Oct 17, 2024
1 parent 0f59bba commit c8f3a6d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ pandoc_fragment = function(text, to = pandoc_to(), from = pandoc_from()) {
#' @examples fig_path('.pdf', options = list(fig.path='figure/abc-', label='first-plot'))
#' fig_path('.png', list(fig.path='foo-', label='bar'), 1:10)
fig_path = function(suffix = '', options = opts_current$get(), number) {
if (suffix != '' && !grepl('[.]', suffix)) suffix = paste0('.', suffix)
suffix = sub('^([^.])', '.\\1', suffix)
if (missing(number)) number = options$fig.cur %n% 1L
if (!is.null(number)) suffix = paste0('-', number, suffix)
path = valid_path(options$fig.path, options$label)
Expand Down

0 comments on commit c8f3a6d

Please sign in to comment.