Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion R/group_bootstrap.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ group_bootstrap_col <- function(x, j, ihead, ...) {
# midrule on numbered spans (not full columns of body)
jnames <- names(j)
jnames <- seq_along(jnames)[trimws(jnames) != ""]
x <- style_eval(x, i = ihead, j = jnames, line = "b", line_width = .05, line_color = "#d3d8dc")
x <- style_eval(x, i = ihead, j = jnames, line = "b", line_width = 0.05, line_color = "#d3d8dc")

return(x)
}
Expand Down
4 changes: 2 additions & 2 deletions R/group_tabularray.R
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ insert_values <- function(vec, values, positions) {
positions <- positions[ord]

# Create a vector of indices for the original vector
original_indices <- 1:length(vec)
original_indices <- seq_along(vec)


# Insert values and update indices
for (i in 1:length(values)) {
for (i in seq_along(values)) {
vec <- append(vec, values[i], after = positions[i] - 1)
original_indices <- append(original_indices, NA, after = positions[i] - 1)
}
Expand Down
2 changes: 1 addition & 1 deletion R/group_typst.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ group_typst_col <- function(x, j, ihead, ...) {
idx <- order(max_col)
j <- j[idx]
lab <- names(j)
len <- sapply(j, length)
len <- lengths(j)
col <- ifelse(
trimws(lab) == "",
sprintf("[%s],", lab),
Expand Down
2 changes: 1 addition & 1 deletion R/style_bootstrap.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ setMethod(
alignv = NULL,
line = NULL,
line_color = "black",
line_width = .1,
line_width = 0.1,
colspan = NULL,
rowspan = NULL,
indent = 0,
Expand Down
2 changes: 1 addition & 1 deletion R/style_tabularray.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ setMethod(
alignv = NULL,
line = NULL,
line_color = "black",
line_width = .1,
line_width = 0.1,
colspan = NULL,
rowspan = NULL,
indent = 0,
Expand Down
2 changes: 1 addition & 1 deletion R/style_tt.R
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ style_tt_lazy <- function (x,
msg <- sprintf("`align` must be a single character or a string of length %s.", nalign)
stop(msg, call. = FALSE)
}
if (any(!align %in% c("c", "l", "r", "d"))) {
if (!all(align %in% c("c", "l", "r", "d"))) {
msg <- "`align` must be characters c, l, r, or d."
stop(msg, call. = FALSE)
}
Expand Down
4 changes: 2 additions & 2 deletions R/style_typst.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ setMethod(
align = NULL,
line = NULL,
line_color = "black",
line_width = .1,
line_width = 0.1,
colspan = NULL,
indent = 0,
midrule = FALSE, # undocumented, only used by `group_tt()`
Expand Down Expand Up @@ -132,7 +132,7 @@ setMethod(
out <- lines_drop(out, "// tinytable align-default-array here", fixed = TRUE)
out <- lines_insert(out, align_default, "tinytable align-default-array after", "after")
} else if (length(align_value) %in% c(1, length(ival) * length(jval))) {
if (length(align_value == 1)) align_value <- rep(align_value, length(ival) * length(jval))
if (length(align_value) == 1) align_value <- rep(align_value, length(ival) * length(jval))
counter <- 0
for (k in ival) {
for (w in jval) {
Expand Down
18 changes: 9 additions & 9 deletions R/theme_tt.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
theme_default <- function(x, ...) {
fn <- function(table) {
if (isTRUE(table@output == "typst")) {
table <- style_eval(table, i = 1 - table@nhead, line = "t", line_width = .1)
table <- style_eval(table, i = 0, line = "b", line_width = .05)
table <- style_eval(table, i = nrow(table), line = "b", line_width = .1)
table <- style_eval(table, i = 1 - table@nhead, line = "t", line_width = 0.1)
table <- style_eval(table, i = 0, line = "b", line_width = 0.05)
table <- style_eval(table, i = nrow(table), line = "b", line_width = 0.1)
}

return(table)
Expand Down Expand Up @@ -165,12 +165,12 @@ theme_striped <- function(x, ...) {
assert_class(x, "tinytable")
fn <- function(table) {
if (isTRUE(table@output == "typst")) {
table <- style_eval(table, i = 1 - table@nhead, line = "t", line_width = .1)
table <- style_eval(table, i = 0, line = "b", line_width = .05)
table <- style_eval(table, i = nrow(table), line = "b", line_width = .1)
table <- style_eval(table, i = 1 - table@nhead, line = "t", line_width = .1)
table <- style_eval(table, i = 0, line = "b", line_width = .05)
table <- style_eval(table, i = nrow(table), line = "b", line_width = .1)
table <- style_eval(table, i = 1 - table@nhead, line = "t", line_width = 0.1)
table <- style_eval(table, i = 0, line = "b", line_width = 0.05)
table <- style_eval(table, i = nrow(table), line = "b", line_width = 0.1)
table <- style_eval(table, i = 1 - table@nhead, line = "t", line_width = 0.1)
table <- style_eval(table, i = 0, line = "b", line_width = 0.05)
table <- style_eval(table, i = nrow(table), line = "b", line_width = 0.1)
table <- style_eval(table, i = seq(1, nrow(table), by = 2), background = "#ededed")
}
return(table)
Expand Down
2 changes: 1 addition & 1 deletion R/tt_bootstrap.R
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ setMethod(

if (is.null(x@theme[[1]]) || is.function(x@theme[[1]]) || isTRUE("default" %in% x@theme[[1]])) {
x <- style_eval(x, bootstrap_class = "table table-borderless",
i = 0, line = "b", line_color = "#d3d8dc", line_width = .1)
i = 0, line = "b", line_color = "#d3d8dc", line_width = 0.1)
} else if ("bootstrap" %in% x@theme[[1]]) {
x <- style_eval(x, bootstrap_class = "table")
} else if ("striped" %in% x@theme[[1]]) {
Expand Down
4 changes: 2 additions & 2 deletions R/tt_grid.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ tt_eval_grid <- function(x, width_cols = NULL, ...) {
tab <- matrix(padded, ncol = ncol(tab))

if (is.null(width_cols) || length(width_cols) == 0) {
for (j in 1:ncol(tab)) {
for (j in seq_len(ncol(tab))) {
if (isTRUE(check_dependency("fansi"))) {
width_cols[j] <- max(nchar(as.character(fansi::strip_ctl(tab[, j]))))
} else {
Expand All @@ -56,7 +56,7 @@ tt_eval_grid <- function(x, width_cols = NULL, ...) {
}
}

for (j in 1:ncol(x)) {
for (j in seq_len(ncol(x))) {
if (isTRUE(check_dependency("fansi"))) {
nc <- nchar(fansi::strip_ctl(tab[, j]))
} else {
Expand Down
2 changes: 1 addition & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ttempdir <- function() {

lines_drop_consecutive_empty <- function(x) {
lines <- strsplit(x, "\n")[[1]]
tmp = rle(lines)
tmp <- rle(lines)
tmp$lengths[trimws(tmp$values) == ""] <- 1
lines <- inverse.rle(tmp)
x <- paste0(lines, collapse = "\n")
Expand Down