Skip to content

Commit

Permalink
Use new version of has_crop_tools() from knitr (#2532)
Browse files Browse the repository at this point in the history
It handles new windows specificity regarding ghostscript

Context at yihui/knitr#2246
  • Loading branch information
cderv authored Dec 11, 2023
1 parent 0951a2f commit 7187bd8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Imports:
htmltools (>= 0.5.1),
jquerylib,
jsonlite,
knitr (>= 1.22),
knitr (>= 1.43),
methods,
tinytex (>= 0.31),
tools,
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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
================================================================================
Expand Down
15 changes: 1 addition & 14 deletions R/util.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 7187bd8

Please sign in to comment.