Is there a way for a document to detect that it is being produced with output: markdown::html_format? I would like to use that output format for rgl vignettes, because then they will work even if Pandoc is not available. However, I need to distinguish HTML output from LaTeX output, because the former doesn't need PNG snapshots, whereas the latter does.
My previous test looked at knitr::pandoc_to(), but that doesn't appear to work with markdown::html_format when running R CMD build. It evaluates to a blank.
The logic I'm hoping for is something like this (a modified version of rgl:::knitrNeedsSnapshot):
knitrNeedsSnapshot <- function(options = knitr::opts_current$get()) {
if (!is.null(options$snapshot))
return(options$snapshot)
if (isFALSE(options$screenshot.force))
return(FALSE)
force <- isTRUE(options$screenshot.force)
if (isMarkdownHTMLformat())
return(FALSE)
fmt <- pandoc_to()
if (!length(fmt) || force)
return(TRUE)
html_format <- fmt %in% c("html", "html4", "html5", "revealjs",
"s5", "slideous", "slidy")
!html_format
}
but so far I haven't got a reliable isMarkdownHTMLformat() function.
Is there a way for a document to detect that it is being produced with
output: markdown::html_format
? I would like to use that output format forrgl
vignettes, because then they will work even if Pandoc is not available. However, I need to distinguish HTML output from LaTeX output, because the former doesn't need PNG snapshots, whereas the latter does.My previous test looked at
knitr::pandoc_to()
, but that doesn't appear to work withmarkdown::html_format
when runningR CMD build
. It evaluates to a blank.The logic I'm hoping for is something like this (a modified version of
rgl:::knitrNeedsSnapshot
):but so far I haven't got a reliable
isMarkdownHTMLformat()
function.