From ab708607afeb3715c0c64d44569a3166e392409a Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Wed, 8 Feb 2023 15:16:46 +0100 Subject: [PATCH] Add support for webtex in blastula_email rmarkodwn format --- R/blastula_email_format.R | 14 +++++++++++++- man/blastula_email.Rd | 8 ++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/R/blastula_email_format.R b/R/blastula_email_format.R index 2a91784f..1a7170c4 100644 --- a/R/blastula_email_format.R +++ b/R/blastula_email_format.R @@ -32,6 +32,12 @@ #' default, this is `TRUE`. The standalone HTML file will have no external #' dependencies, it will use URIs to incorporate the contents of linked #' scripts, stylesheets, images, and videos. +#' @param math_method Passed to `math_method` in [rmarkdown::html_document()]. +#' Only method `webtex` is supported at the moment to generate math as svg +#' image (default), or png (by specifying a url). See details in +#' [rmarkdown::html_document()]. Set to `NULL` to deactivate math processing. +#' _Note: Using `webtex` requires a internet connection when rendering the +#' document as an external service is used. #' @param template The Pandoc template to use for rendering. This is the #' `"blastula"` template by default. #' @param includes A named list of additional content to include within the @@ -59,6 +65,7 @@ blastula_email <- function(content_width = "1000px", dev = "png", smart = TRUE, self_contained = TRUE, + math_method = "webtex", template = "blastula", includes = NULL, keep_md = FALSE, @@ -72,6 +79,10 @@ blastula_email <- function(content_width = "1000px", template <- system.file("rmd", "template.html", package = "blastula") } + if (!is.null(math_method) && math_method != "webtex") { + stop("Only 'webtex' method is for now supported when math is activated.") + } + # Note bash escaping is handled by R Markdown (via shQuote()) pandoc_args <- paste0("--variable=content-width:", content_width) if (isTRUE(connect_footer)) { @@ -111,7 +122,8 @@ blastula_email <- function(content_width = "1000px", self_contained = self_contained, theme = "default", highlight = "default", - mathjax = NULL, + math_method = math_method, + mathjax = "default", template = template, extra_dependencies = NULL, css = NULL, diff --git a/man/blastula_email.Rd b/man/blastula_email.Rd index e213a9f2..4d282d6b 100644 --- a/man/blastula_email.Rd +++ b/man/blastula_email.Rd @@ -18,6 +18,7 @@ blastula_email( dev = "png", smart = TRUE, self_contained = TRUE, + math_method = "webtex", template = "blastula", includes = NULL, keep_md = FALSE, @@ -71,6 +72,13 @@ default, this is \code{TRUE}. The standalone HTML file will have no external dependencies, it will use URIs to incorporate the contents of linked scripts, stylesheets, images, and videos.} +\item{math_method}{Passed to \code{math_method} in \code{\link[rmarkdown:html_document]{rmarkdown::html_document()}}. +Only method \code{webtex} is supported at the moment to generate math as svg +image (default), or png (by specifying a url). See details in +\code{\link[rmarkdown:html_document]{rmarkdown::html_document()}}. Set to \code{NULL} to deactivate math processing. +_Note: Using \code{webtex} requires a internet connection when rendering the +document as an external service is used.} + \item{template}{The Pandoc template to use for rendering. This is the \code{"blastula"} template by default.}