From 5a5cb5d115cf14ecf1a6869ab8217fb00d658c73 Mon Sep 17 00:00:00 2001 From: Vincent Arel-Bundock Date: Sat, 14 Sep 2024 08:27:11 -0400 Subject: [PATCH] group_tt nhead adjustment --- R/group_typst.R | 2 +- ...ssue-139_misaligned_rule_with_group_tt.txt | 20 +++++++++---------- inst/tinytest/test-typst.R | 4 ---- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/R/group_typst.R b/R/group_typst.R index 9991b248..36d14ba1 100644 --- a/R/group_typst.R +++ b/R/group_typst.R @@ -37,7 +37,7 @@ group_typst_row <- function(x, i, indent, ...) { tab <- c(top, mid, bot) tab <- paste(tab, collapse = "\n") x@table_string <- tab - idx_new <- i + seq_along(i) - 1 + idx_new <- i + seq_along(i) + x@nhead - 2 idx_old <- setdiff(seq_len(nrow(x)), idx_new) x <- style_tt(x, idx_old, indent = indent) return(x) diff --git a/inst/tinytest/_tinysnapshot/typst-issue-139_misaligned_rule_with_group_tt.txt b/inst/tinytest/_tinysnapshot/typst-issue-139_misaligned_rule_with_group_tt.txt index 05eda477..204d421d 100644 --- a/inst/tinytest/_tinysnapshot/typst-issue-139_misaligned_rule_with_group_tt.txt +++ b/inst/tinytest/_tinysnapshot/typst-issue-139_misaligned_rule_with_group_tt.txt @@ -44,51 +44,51 @@ block[ // start block (y: 12, x: 4, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 11, x: 4, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 10, x: 4, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), - (y: 9, x: 4, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), + (y: 8, x: 4, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 7, x: 4, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 6, x: 4, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 5, x: 4, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), - (y: 4, x: 4, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), + (y: 3, x: 4, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 2, x: 4, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 13, x: 3, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 12, x: 3, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 11, x: 3, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 10, x: 3, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), - (y: 9, x: 3, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), + (y: 8, x: 3, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 7, x: 3, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 6, x: 3, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 5, x: 3, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), - (y: 4, x: 3, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), + (y: 3, x: 3, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 2, x: 3, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 13, x: 2, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 12, x: 2, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 11, x: 2, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 10, x: 2, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), - (y: 9, x: 2, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), + (y: 8, x: 2, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 7, x: 2, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 6, x: 2, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 5, x: 2, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), - (y: 4, x: 2, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), + (y: 3, x: 2, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 2, x: 2, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 13, x: 1, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 12, x: 1, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 11, x: 1, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 10, x: 1, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), - (y: 9, x: 1, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), + (y: 8, x: 1, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 7, x: 1, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 6, x: 1, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 5, x: 1, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), - (y: 4, x: 1, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), + (y: 3, x: 1, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 2, x: 1, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 13, x: 0, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 12, x: 0, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 11, x: 0, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 10, x: 0, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), - (y: 9, x: 0, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), + (y: 8, x: 0, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 7, x: 0, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 6, x: 0, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 5, x: 0, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), - (y: 4, x: 0, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), + (y: 3, x: 0, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 2, x: 0, color: black, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: 1em), (y: 6, x: 4, color: white, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: false), (y: 5, x: 4, color: white, underline: false, italic: false, bold: false, mono: false, strikeout: false, fontsize: 1em, indent: false), diff --git a/inst/tinytest/test-typst.R b/inst/tinytest/test-typst.R index 182b48aa..fafca754 100644 --- a/inst/tinytest/test-typst.R +++ b/inst/tinytest/test-typst.R @@ -5,15 +5,11 @@ options(tinytable_print_output = "typst") # semi complicated -# Q -# pkgload::load_all() tab <- tt(mtcars[1:4, 1:5], caption = "Hello World") |> group_tt(j = list("Group 1" = 4:5, "Group 2" = 2:3)) |> style_tt(j = 1:5, align = "lcccr") |> style_tt(i = 2, j = 1:3, strikeout = TRUE, bold = TRUE, background = "black", color = "white") |> style_tt(j = 1, color = "red", italic = TRUE) -# print(tab) - expect_snapshot_print(tab, label = "typst-complicated")