Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove stringr dependency #2530

Merged
merged 5 commits into from
Dec 5, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
simplify the code by using regmatches<-
  • Loading branch information
yihui committed Dec 5, 2023
commit d3c54ef76311e1f34dfdcf17c9d88787cdf29521
10 changes: 2 additions & 8 deletions R/base64.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,9 @@ process_html_res <- function(html, reg, processor) {
character(1)
)
}
m <- gregexpr(reg, html, perl = TRUE)
regmatches(html, m) <- lapply(regmatches(html, m), process_img_src)

# base R alternative to stringr::str_replace_all() with a function in
# replacement
mtchs <- regmatches(html, gregexpr(reg, html, perl = TRUE))[[1]]
if (length(mtchs) > 0) {
for (i in rev(mtchs)) {
html <- gsub(i, process_img_src(i), html, fixed = TRUE)
}
}
strsplit(html, "\n", fixed = TRUE)[[1]]
}

Expand Down