Skip to content

Commit

Permalink
fix: improve error checking for plot hook
Browse files Browse the repository at this point in the history
- check image is not an url
- mention in the manual

fix #146
  • Loading branch information
davidgohel committed Oct 27, 2024
1 parent fbaa3c2 commit 2f89c87
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: officedown
Type: Package
Title: Enhanced 'R Markdown' Format for 'Word' and 'PowerPoint'
Version: 0.4.0.002
Version: 0.4.0.003
Authors@R: c(
person("David", "Gohel", role = c("aut", "cre", "cph"),
email = "[email protected]"),
Expand All @@ -26,13 +26,13 @@ License: MIT + file LICENSE
Encoding: UTF-8
Imports: knitr,
rmarkdown,
officer (>= 0.5.1),
officer (>= 0.6.7),
xml2, rlang, uuid,
grDevices, yaml, utils, memoise,
rvg (>= 0.2.2)
rvg (>= 0.3.4)
Suggests:
ggplot2,
flextable (>= 0.7.0),
flextable (>= 0.9.7),
bookdown (>= 0.13),
testthat (>= 3.0.0),
doconv (>= 0.3.0)
Expand Down
5 changes: 5 additions & 0 deletions R/hooks.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ knitr_opts_current <- function(x, default = FALSE){
#' @noRd
plot_word_fig_caption <- function(x, options) {

if (grepl("^(ftp|ftps|http|https)://", x[1])) {
stop("Images in 'rdocx_document' must be local files accessible without an internet connection:\n",
shQuote(x[1]), call. = FALSE)
}

if(!is.character(options$fig.cap)) options$fig.cap <- NULL
if(!is.character(options$fig.alt)) options$fig.alt <- NULL
if(is.null(options$fig.id))
Expand Down
5 changes: 4 additions & 1 deletion R/rdocx_document.R
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,10 @@ get_reference_rdocx <- memoise(get_docx_uncached)
#'
#' ```{r child = "man/rdocx/rmarkdown-yaml.Rmd"}
#' ```
#'
#' @section Known limitations:
#' When using `knitr::include_graphics()` in 'rdocx_document',
#' the image must be local, while with standard 'R Markdown'
#' output documents, images located on Internet are supported.
#' @examples
#' # rdocx_document basic example -----
#' @example examples/rdocx_document.R
Expand Down
7 changes: 7 additions & 0 deletions man/rdocx_document.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2f89c87

Please sign in to comment.