From 47dfb217bb47e3ea1052f68f8fc9f0edae11cec7 Mon Sep 17 00:00:00 2001 From: philchalmers Date: Mon, 9 Sep 2024 08:51:25 -0400 Subject: [PATCH] allow global setting of preview --- R/Eqn.R | 9 ++++++--- man/Eqn.Rd | 8 +++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/R/Eqn.R b/R/Eqn.R index f77e062b..42cea836 100644 --- a/R/Eqn.R +++ b/R/Eqn.R @@ -47,8 +47,10 @@ #' each \code{matrix} object supplied. If further specificity is required create #' \code{\link{latexMatrix}} objects directly. #' @param preview logical; render an HTML version of the equation and display? This is intended for -#' testing purposes and is only applicable to interactive R sessions. Disabled -#' whenever \code{quarto} or \code{html_output} are \code{TRUE} +#' testing purposes and is only applicable to interactive R sessions, though +#' for code testing purposes can be set globally +#' via \code{\link{options}} (e.g., \code{options('previewEqn' = FALSE)}). +#' Disabled whenever \code{quarto} or \code{html_output} are \code{TRUE} #' @returns NULL #' @importFrom knitr is_html_output #' @importFrom rstudioapi viewer @@ -112,7 +114,7 @@ Eqn <- function(..., label = NULL, align = FALSE, - preview = TRUE, + preview = getOption('previewEqn'), html_output = knitr::is_html_output(), quarto = getOption('quartoEqn'), mat_args = list()) { @@ -126,6 +128,7 @@ Eqn <- function(..., } } on.exit(sink.reset()) + if(is.null(preview)) preview <- TRUE quarto <- setQuartoEqn(quarto) if(is.null(quarto)) quarto <- FALSE preview <- preview && interactive() diff --git a/man/Eqn.Rd b/man/Eqn.Rd index af2e3a60..6eddcd42 100644 --- a/man/Eqn.Rd +++ b/man/Eqn.Rd @@ -14,7 +14,7 @@ Eqn( ..., label = NULL, align = FALSE, - preview = TRUE, + preview = getOption("previewEqn"), html_output = knitr::is_html_output(), quarto = getOption("quartoEqn"), mat_args = list() @@ -63,8 +63,10 @@ ref( points. Default: \code{FALSE}} \item{preview}{logical; render an HTML version of the equation and display? This is intended for -testing purposes and is only applicable to interactive R sessions. Disabled -whenever \code{quarto} or \code{html_output} are \code{TRUE}} +testing purposes and is only applicable to interactive R sessions, though +for code testing purposes can be set globally +via \code{\link{options}} (e.g., \code{options('previewEqn' = FALSE)}). +Disabled whenever \code{quarto} or \code{html_output} are \code{TRUE}} \item{html_output}{logical; use labels for HTML outputs instead of the LaTeX? Automatically changed for compiled documents that support \code{knitr}. Generally not