Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for math in blastula_email rmarkdown format #298

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion R/blastula_email_format.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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)) {
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions man/blastula_email.Rd

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