Skip to content

Commit

Permalink
typst duplicate cells fix. Still very borkened
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentarelbundock committed Oct 26, 2024
1 parent 239b0e4 commit 442a0ba
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion R/group_typst.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ group_typst_row <- function(x, i, indent, ...) {
idx_new <- i + seq_along(i) - 1
idx_all <- seq_len(nrow(x) + length(i))
idx <- setdiff(idx_all, idx_new)
x <- style_tt(x, idx, indent = indent)
# x <- style_tt(x, idx, indent = indent)
return(x)
}

Expand Down
2 changes: 1 addition & 1 deletion R/style_typst.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ style_apply_typst <- function(x) {
css <- sub("^,", "", trimws(css))
css <- gsub(",+", ",", trimws(css))
rec$css <- css
rec <- rec[rec$css != "", ]

# TODO: spans before styles, as in bootstrap

# Unique style arrays
Expand Down
22 changes: 10 additions & 12 deletions inst/templates/typst.typ
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,19 @@ block[ // start block
if style-array.len() == 0 {
it
} else {
let tmp = it
for style in style-array {
let tmp = it
let m = style.pairs.find(k => k.at(0) == it.x and k.at(1) == it.y)
if m != none {
if ("fontsize" in style) { tmp = text(size: style.fontsize, tmp) }
if ("color" in style) { tmp = text(fill: style.color, tmp) }
if ("indent" in style) { tmp = pad(left: style.indent, tmp) }
if ("underline" in style) { tmp = underline(tmp) }
if ("italic" in style) { tmp = emph(tmp) }
if ("bold" in style) { tmp = strong(tmp) }
if ("mono" in style) { tmp = math.mono(tmp) }
if ("strikeout" in style) { tmp = strike(tmp) }
}
tmp
if ("fontsize" in style) { tmp = text(size: style.fontsize, tmp) }
if ("color" in style) { tmp = text(fill: style.color, tmp) }
if ("indent" in style) { tmp = pad(left: style.indent, tmp) }
if ("underline" in style) { tmp = underline(tmp) }
if ("italic" in style) { tmp = emph(tmp) }
if ("bold" in style) { tmp = strong(tmp) }
if ("mono" in style) { tmp = math.mono(tmp) }
if ("strikeout" in style) { tmp = strike(tmp) }
}
tmp
}
}

Expand Down

0 comments on commit 442a0ba

Please sign in to comment.