From 02e056f043342fbc8e43464e18152bb31355090d Mon Sep 17 00:00:00 2001 From: Vincent Arel-Bundock Date: Wed, 24 Jan 2024 10:04:05 -0500 Subject: [PATCH] defensive programming --- R/finalize_bootstrap.R | 2 +- R/finalize_grid.R | 2 +- R/format_tt.R | 4 ++-- R/plot_tt.R | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/R/finalize_bootstrap.R b/R/finalize_bootstrap.R index 3719cb00..06550157 100644 --- a/R/finalize_bootstrap.R +++ b/R/finalize_bootstrap.R @@ -1,6 +1,6 @@ finalize_bootstrap <- function(x) { - if (meta(x)$output != "html") return(x) + if (!isTRUE(meta(x)$output == "html")) return(x) out <- gsub( "$tinytable_BOOTSTRAP_CLASS", "table", diff --git a/R/finalize_grid.R b/R/finalize_grid.R index 2676f43e..7591e40a 100644 --- a/R/finalize_grid.R +++ b/R/finalize_grid.R @@ -1,6 +1,6 @@ finalize_grid <- function(x) { - if (meta(x)$output != "markdown") return(x) + if (!isTRUE(meta(x)$output == "markdown")) return(x) out <- x diff --git a/R/format_tt.R b/R/format_tt.R index 0df983c9..4eb7d39d 100644 --- a/R/format_tt.R +++ b/R/format_tt.R @@ -199,7 +199,7 @@ format_tt_lazy <- function(x, if (isTRUE(markdown)) { assert_dependency("markdown") for (col in j) { - if (meta(x)$output == "html") { + if (isTRUE(meta(x)$output == "html")) { fun <- function(x) { out <- trimws(markdown::mark_html(text = x, template = FALSE)) out <- sub("

", "", out, fixed = TRUE) @@ -207,7 +207,7 @@ format_tt_lazy <- function(x, return(out) } x[, col] <- sapply(x[, col], fun) - } else if (meta(x)$output == "latex") { + } else if (isTRUE(meta(x)$output == "latex")) { fun <- function(x) trimws(markdown::mark_latex(text = x, template = FALSE)) x[, col] <- sapply(x[, col], fun) } diff --git a/R/plot_tt.R b/R/plot_tt.R index f82ee4aa..ba335ac6 100644 --- a/R/plot_tt.R +++ b/R/plot_tt.R @@ -188,18 +188,18 @@ plot_tt_lazy <- function(x, } } - if (meta(x)$output == "latex") { + if (isTRUE(meta(x)$output == "latex")) { cell <- "\\includegraphics[height=%sem]{%s}" cell <- sprintf(cell, height, images) - } else if (meta(x)$output == "html") { + } else if (isTRUE(meta(x)$output == "html")) { cell <- ifelse( grepl("^http", trimws(images)), '', '') cell <- sprintf(cell, images, height) - } else if (meta(x)$output == "markdown") { + } else if (isTRUE(meta(x)$output == "markdown")) { cell <- '![](%s)' cell <- sprintf(cell, images)