Skip to content

Commit

Permalink
Remove stringr dependency (#2530)
Browse files Browse the repository at this point in the history
Co-authored-by: Yihui Xie <[email protected]>
  • Loading branch information
etiennebacher and yihui authored Dec 5, 2023
1 parent dde9fe3 commit 72cd623
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 22 deletions.
14 changes: 1 addition & 13 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# CITATION file created with {cffr} R package, v0.4.1
# See also: https://docs.ropensci.org/cffr/
# -----------------------------------------------------------

cff-version: 1.2.0
message: 'To cite package "rmarkdown" in publications use:'
type: software
Expand Down Expand Up @@ -271,18 +271,6 @@ references:
year: '2023'
institution:
name: R Foundation for Statistical Computing
- type: software
title: stringr
abstract: 'stringr: Simple, Consistent Wrappers for Common String Operations'
notes: Imports
url: https://stringr.tidyverse.org
repository: https://CRAN.R-project.org/package=stringr
authors:
- family-names: Wickham
given-names: Hadley
email: [email protected]
year: '2023'
version: '>= 1.2.0'
- type: software
title: tinytex
abstract: 'tinytex: Helper Functions to Install and Maintain TeX Live, and Compile
Expand Down
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ Imports:
jsonlite,
knitr (>= 1.22),
methods,
stringr (>= 1.2.0),
tinytex (>= 0.31),
tools,
utils,
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ rmarkdown 2.26

- 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).


rmarkdown 2.25
================================================================================
Expand Down
4 changes: 3 additions & 1 deletion R/base64.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ process_html_res <- function(html, reg, processor) {
character(1)
)
}
html <- stringr::str_replace_all(html, reg, process_img_src)
m <- gregexpr(reg, html, perl = TRUE)
regmatches(html, m) <- lapply(regmatches(html, m), process_img_src)

strsplit(html, "\n", fixed = TRUE)[[1]]
}

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/site/PageA.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ knitr::opts_chunk$set(echo = TRUE)
Let's load a package (from existing dependencies) and make sure it's not on the search path when rendering a subsequent file.

```{r}
library(stringr)
library(tinytex)
plot(cars)
```

Expand Down
12 changes: 6 additions & 6 deletions tests/testthat/test-site.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ test_that("render_site respects 'new_session' in the config", {
a <- readLines(file.path(site_dir, "_site", "PageA.html"))
b <- readLines(file.path(site_dir, "_site", "PageB.html"))

# pkg loaded in PageA (stringr) should show up in search path of PageB
expect_match(a, "library(stringr)", fixed = TRUE, all = FALSE)
expect_true(any(grepl("stringr", b, fixed = TRUE)))
# pkg loaded in PageA (tinytex) should show up in search path of PageB
expect_match(a, "library(tinytex)", fixed = TRUE, all = FALSE)
expect_true(any(grepl("tinytex", b, fixed = TRUE)))

# edit config --> new_session: true
cat("new_session: true", file = file.path(site_dir, "_site.yml"), append = TRUE)
Expand All @@ -77,9 +77,9 @@ test_that("render_site respects 'new_session' in the config", {
a <- readLines(file.path(site_dir, "_site", "PageA.html"))
b <- readLines(file.path(site_dir, "_site", "PageB.html"))

# pkg loaded in PageA (stringr) should NOT show up in search path of PageB
expect_match(a, "library(stringr)", fixed = TRUE, all = FALSE)
expect_false(any(grepl("stringr", b, fixed = TRUE)))
# pkg loaded in PageA (tinytex) should NOT show up in search path of PageB
expect_match(a, "library(tinytex)", fixed = TRUE, all = FALSE)
expect_false(any(grepl("tinytex", b, fixed = TRUE)))
})

test_that("clean_site gives notices before removing", {
Expand Down

0 comments on commit 72cd623

Please sign in to comment.