From 7187bd839863b402ce4423f7a22551a2ea102c46 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Mon, 11 Dec 2023 18:23:09 +0100 Subject: [PATCH] Use new version of `has_crop_tools()` from knitr (#2532) It handles new windows specificity regarding ghostscript Context at yihui/knitr#2246 --- DESCRIPTION | 2 +- NEWS.md | 4 ++++ R/util.R | 15 +-------------- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index f6df81383f..d214d8c684 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -63,7 +63,7 @@ Imports: htmltools (>= 0.5.1), jquerylib, jsonlite, - knitr (>= 1.22), + knitr (>= 1.43), methods, tinytex (>= 0.31), tools, diff --git a/NEWS.md b/NEWS.md index 467e802313..eb8ca5dfe0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,10 +1,14 @@ rmarkdown 2.26 ================================================================================ +- **rmarkdown** now requires **knitr** >= 1.43. + - Get rid of the superfluous warning in `find_pandoc()` (thanks, @jszhao, #2527). - Removed the **stringr** dependency since it is used only once in the package and the equivalent base R code is simple enough (thanks, @etiennebacher, #2530). +- For the output format option `fig_crop: auto`, it will now use the same logic as in **knitr** to decide if cropping is possible (yihui/knitr#2246). + rmarkdown 2.25 ================================================================================ diff --git a/R/util.R b/R/util.R index e3396b9424..5cac75155a 100644 --- a/R/util.R +++ b/R/util.R @@ -315,20 +315,7 @@ find_program <- function(program) { } } -has_crop_tools <- function(warn = TRUE) { - tools <- c( - pdfcrop = unname(find_program("pdfcrop")), - ghostscript = unname(tools::find_gs_cmd()) - ) - missing <- tools[tools == ""] - if (length(missing) == 0) return(TRUE) - x <- paste0(names(missing), collapse = ", ") - if (warn) warning( - sprintf("\nTool(s) not installed or not in PATH: %s", x), - "\n-> As a result, figure cropping will be disabled." - ) - FALSE -} +has_crop_tools <- function(...) knitr:::has_crop_tools(...) # given a string, escape the regex metacharacters it contains: # regex metas are these,