Skip to content

Commit

Permalink
respect CRAN mirror settings
Browse files Browse the repository at this point in the history
  • Loading branch information
s-u committed Nov 21, 2023
1 parent 267e336 commit 3bbfecd
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions R/rj_article.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ rjournal_article <- function(toc = FALSE, self_contained = FALSE,
ctvs <- local_cache$get("ctv")
} else {
ctvs <- readRDS(
gzcon(url("https://cran.r-project.org/src/contrib/Views.rds", open = "rb"))
gzcon(url(.cran("/src/contrib/Views.rds"), open = "rb"))
)
local_cache$add(ctvs, "ctv")
}
Expand Down Expand Up @@ -153,7 +153,7 @@ rjournal_article <- function(toc = FALSE, self_contained = FALSE,

# Add embedded PDF to HTML stubs
is_stub <- !any(grepl("^\\s*#+\\s*.*", body))
embed_pdf <- if(legacy_pdf && is_stub){
embed_pdf <- if(isTRUE(metadata$tex_native) || (legacy_pdf && is_stub)) {
whisker::whisker.render(
'<div class="l-page">
<embed src="{{slug}}.pdf" type="application/pdf" height="955px" width="100%">
Expand Down Expand Up @@ -331,3 +331,13 @@ rjournal_article <- function(toc = FALSE, self_contained = FALSE,
base_format = base_format
)
}

.cran <- function(path="") {
cran <- "http://cran.R-project.org"
rep <- getOption("repos")
if ("CRAN" %in% names(rep)) {
opt <- rep["CRAN"]
if (opt != "@CRAN@") cran <- opt
}
paste0(cran, path)
}

0 comments on commit 3bbfecd

Please sign in to comment.