Skip to content

Commit

Permalink
fix for R <4.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
HenningLorenzen-ext-bayer committed Jul 12, 2024
1 parent e579b7d commit ea73a3c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion R/check-built.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ check_missing_images <- function(pkg, src_path, dst_path) {
img <- xml2::xml_find_all(html, ".//img")
src <- xml2::xml_attr(img, "src")

rel_src <- utils::URLdecode(src[xml2::url_parse(src)$scheme == ""])
rel_src <-
purrr::map_chr(.x = src[xml2::url_parse(src)$scheme == ""],
.f = utils::URLdecode)
rel_path <- path_norm(path(path_dir(dst_path), rel_src))
exists <- file_exists(path(pkg$dst_path, rel_path))

Expand Down
10 changes: 8 additions & 2 deletions R/tweak-page.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,16 @@ tweak_rmarkdown_html <- function(html, input_path, pkg = list(bs_version = 3)) {
abs_src <- is_absolute_path(src)
if (any(abs_src)) {
img_target_nodes <- img[abs_src]
img_src_real <- path_real(utils::URLdecode(src[abs_src]))

img_src_real <-
purrr::map_chr(.x = src[abs_src], .f = utils::URLdecode)
img_src_real <- path_real(img_src_real)

input_path_real <- path_real(utils::URLdecode(input_path))

img_rel_paths <- path_rel(path = img_src_real, start = input_path_real)
img_rel_paths <- utils::URLencode(URL = img_rel_paths)
img_rel_paths <-
purrr::map_chr(.x = img_rel_paths, .f = utils::URLencode)

purrr::walk2(
.x = img_target_nodes,
Expand Down

0 comments on commit ea73a3c

Please sign in to comment.