forked from rstudio/rmarkdown
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'jg-devel' * jg-devel: Use new version of `has_crop_tools()` from knitr (rstudio#2532) some cosmetic changes use ignore.case = TRUE for regex functions instead of enumerating upper/lowercase letters Remove `stringr` dependency (rstudio#2530) Add a mention about required configuration when erroring about webshot and webshot2 Fixed documentation problems with `publish_site()` # Conflicts: # R/publish_site.R
- Loading branch information
Showing
9 changed files
with
28 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,30 @@ | ||
# processes an HTML resource, given a regular expression that locates | ||
# instances of that resource | ||
process_html_res <- function(html, reg, processor) { | ||
html <- one_string(html) | ||
process_img_src <- function(img_src) { | ||
src <- sub(reg, '\\1', img_src) | ||
m <- gregexpr(reg, html, perl = TRUE, ignore.case = TRUE) | ||
regmatches(html, m) <- lapply(regmatches(html, m), function(img_src) { | ||
src <- sub(reg, '\\1', img_src, ignore.case = TRUE) | ||
vapply( | ||
seq_along(img_src), | ||
function(i) processor(img_src[[i]], src[[i]]), | ||
character(1) | ||
) | ||
} | ||
html <- stringr::str_replace_all(html, reg, process_img_src) | ||
strsplit(html, "\n", fixed = TRUE)[[1]] | ||
}) | ||
html | ||
} | ||
|
||
process_images <- function(html, processor) { | ||
process_html_res( | ||
html, | ||
"<\\s*[Ii][Mm][Gg]\\s+.*?[Ss][Rr][Cc]\\s*=\\s*[\"']([^\"']+)[\"']", | ||
processor) | ||
process_html_res(html, "<\\s*img\\s+.*?src\\s*=\\s*[\"']([^\"']+)[\"']", processor) | ||
} | ||
|
||
base64_encode_images <- function(html) { | ||
base64_encode_img <- function(img_src, src) { | ||
encode <- function(img_src, src) { | ||
in_file <- utils::URLdecode(src) | ||
if (length(in_file) && file.exists(in_file)) { | ||
img_src <- sub(src, xfun::base64_uri(in_file), img_src, fixed = TRUE) | ||
} | ||
img_src | ||
} | ||
html <- process_images(html, base64_encode_img) | ||
process_html_res(html, "<[^>]*style=\"[^\"]*url\\(([^\\)]+)\\)", base64_encode_img) | ||
html <- process_images(html, encode) | ||
process_html_res(html, "<[^>]*style=\"[^\"]*url\\(([^\\)]+)\\)", encode) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters