diff --git a/R/style_bootstrap.R b/R/style_bootstrap.R index 46ff034a..2c14408b 100644 --- a/R/style_bootstrap.R +++ b/R/style_bootstrap.R @@ -99,7 +99,7 @@ style_bootstrap <- function(x, css_start <- sprintf(".table td.%s, th.%s { ", settings$id[row], settings$id[row]) css_complete <- paste(c(css_start, paste0(settings$bootstrap[row], collapse="; "), "}"), collapse = " ") # hack: avoid css duplication - if (css_complete %in% css_done) { + if (!css_complete %in% css_done) { out <- bootstrap_setting(out, css_complete, component = "css") css_done <- c(css_done, css_complete) } diff --git a/R/style_tabularray.R b/R/style_tabularray.R index 2745c31d..a88711d7 100644 --- a/R/style_tabularray.R +++ b/R/style_tabularray.R @@ -78,13 +78,17 @@ style_tabularray <- function(x, # hex must be treated differently in LaTeX cols <- c(color, background) + cols_done <- NULL if (!is.null(cols)) { hex <- cols[grepl("^#", cols)] for (h in hex) { b <- sprintf( "\\tinytableDefineColor{%s}{HTML}{%s}", sub("^#", "c", h), sub("^#", "", h)) - out <- tabularray_insert(out, content = b, type = "body") + if (!b %in% cols_done) { + out <- tabularray_insert(out, content = b, type = "body") + cols_done <- c(cols_done, b) + } } } if (!is.null(background)) { diff --git a/R/utils.R b/R/utils.R index c1ebd0da..b8fc9670 100644 --- a/R/utils.R +++ b/R/utils.R @@ -34,11 +34,16 @@ meta <- function(x, get, set) { # some rows may be added, which changes how the style is applied eval_style <- function(x) { out <- x + m <- meta(x) - for (l in meta(x)$lazy_style) { + for (l in m$lazy_style) { l[["x"]] <- out out <- eval(eval(l)) } + m <- meta(x) + m$lazy_style <- list() + attr(out, "tinytable_meta") <- m + return(out) } diff --git a/vignettes/tutorial.qmd b/vignettes/tutorial.qmd index 07a3ea41..ef288104 100644 --- a/vignettes/tutorial.qmd +++ b/vignettes/tutorial.qmd @@ -403,7 +403,7 @@ bg <- hcl.colors(20, "Inferno") fg <- ifelse(as.matrix(k) < 17, tail(bg, 1), head(bg, 1)) fs <- 1:20 -tt(k, width = .5, theme = "void") |> +tt(k, width = .5, theme = "void", align = "ccccc") |> style_tt( i = 1:4, j = 1:5,