diff --git a/R/group_bootstrap.R b/R/group_bootstrap.R index 27167919..b49451f0 100644 --- a/R/group_bootstrap.R +++ b/R/group_bootstrap.R @@ -78,7 +78,8 @@ group_bootstrap_row <- function(x, i, j, indent = 1, ...) { idx <- insert_values(seq_len(m$nrows), rep(NA, length(i)), i) idx_old <- idx$new[!is.na(idx$old)] idx_new <- idx$new[is.na(idx$old)] - out <- style_tt(out, i = idx_old, j = 1, indent = indent) + # cannot be style_tt, because we already have a string bootstrap table at this stage + out <- style_bootstrap(out, i = idx_old, j = 1, indent = indent) dots <- list(...) dots[["j"]] <- NULL diff --git a/R/style_bootstrap.R b/R/style_bootstrap.R index b054b22f..e5e9c001 100644 --- a/R/style_bootstrap.R +++ b/R/style_bootstrap.R @@ -83,6 +83,9 @@ style_bootstrap <- function(x, settings$bootstrap <- vectorize_bootstrap(settings$bootstrap, color, "color: %s;") settings$bootstrap <- vectorize_bootstrap(settings$bootstrap, background, "background-color: %s;") settings$bootstrap <- vectorize_bootstrap(settings$bootstrap, width, "width: %s;") + if (indent > 0) { + settings$bootstrap <- paste(settings$bootstrap, sprintf("padding-left: %sem;", indent), sep = "") + } # unique IDs for each CSS style combination id <- sapply(unique(settings$bootstrap), function(k) get_id(stem = "tinytable_css_")) diff --git a/inst/tinytest/test-html.R b/inst/tinytest/test-html.R index 072d77d9..18aac723 100644 --- a/inst/tinytest/test-html.R +++ b/inst/tinytest/test-html.R @@ -34,6 +34,10 @@ tab <- tt(iris[1:10,]) |> group_tt(j = list("Sepal" = 1:2, "Petal" = 3:4)) expect_equal_to_reference(clean(tab), "_tinysnapshot/html-issue58.rds") +# Issue #88: indent +tab <- tt(iris[1:10,]) |> + style_tt(i = 2:4, indent = 3) +expect_equal_to_reference(clean(tab), "_tinysnapshot/html-issue88.rds") # tutorial.qmd: heatmap k <- data.frame(matrix(1:20, ncol = 5))