diff --git a/DESCRIPTION b/DESCRIPTION index 6e714fe..4705ddb 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -24,9 +24,10 @@ Imports: htmltools (>= 0.5.7), jsonlite (>= 0.9.16), knitr (>= 1.8), - rmarkdown, + rlang (>= 1.0.0), yaml Suggests: + rmarkdown, testthat Enhances: shiny (>= 1.1) diff --git a/NEWS.md b/NEWS.md index c7da2b7..8176f72 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # htmlwidgets (development version) +* Moved `{rmarkdown}` from `Imports` to `Suggests`. It's now only required when calling `saveWidget(selfcontained = TRUE)`. (#455) + * htmlwidgets hex sticker added * Static widget resize detection now uses `ResizeObserver` instead of `window.resize`, Bootstrap tab/collapse, and ioslides event listeners. This enables widgets to detect container-level size changes (e.g., CSS-driven resizing, sidebar toggles, flexbox/grid layout changes) that were previously missed. (#496) diff --git a/R/pandoc.R b/R/pandoc.R index 16b236d..2422580 100644 --- a/R/pandoc.R +++ b/R/pandoc.R @@ -1,4 +1,8 @@ -write_md_for_pandoc <- function(html, file, background = "white", title, libdir = "lib", use_raw_attr = rmarkdown::pandoc_available("2.0")) { +write_md_for_pandoc <- function(html, file, background = "white", title, libdir = "lib", use_raw_attr = NULL) { + rlang::check_installed("rmarkdown") + if (is.null(use_raw_attr)) { + use_raw_attr <- rmarkdown::pandoc_available("2.0") + } # Forked from htmltools::save_html to work better with pandoc_self_contained_html # ensure that the paths to dependencies are relative to the base @@ -60,6 +64,7 @@ write_md_for_pandoc <- function(html, file, background = "white", title, libdir # The input should be the path to a file that was created using pandoc_save_markdown pandoc_self_contained_html <- function(input, output) { + rlang::check_installed("rmarkdown") if (!rmarkdown::pandoc_available()) { stop( "Saving a widget with selfcontained = TRUE requires pandoc. ", diff --git a/tests/testthat/test-pandoc.R b/tests/testthat/test-pandoc.R index 3b00b92..cbad8a9 100644 --- a/tests/testthat/test-pandoc.R +++ b/tests/testthat/test-pandoc.R @@ -1,4 +1,5 @@ test_that("Fix for issue #358 works", { + skip_if_not_installed("rmarkdown") skip_if_not( rmarkdown::pandoc_available(), "Test requires pandoc to be installed"