Skip to content

Fancy HTML table not included in typst after latest dev version (works on latest 1.5.47) #10134

@cderv

Description

@cderv

This is not minimal but it is reproducible for me

---
title: fancy gt table
format: typst
---

```{r}
#| echo: false
#| message: false
library(tidyverse)
library(gt)
library(palmerpenguins)

spanners_and_header <- function(gt_tbl) {
  gt_tbl |>
    tab_spanner(
      label = md("**Adelie**"),
      columns = 3:4
    ) |>
    tab_spanner(
      label = md("**Chinstrap**"),
      columns = c("Chinstrap_female", "Chinstrap_male")
    ) |>
    tab_spanner(
      label = md("**Gentoo**"),
      columns = contains("Gentoo")
    ) |>
    tab_header(
      title = "Penguins in the Palmer Archipelago",
      subtitle = "Data is courtesy of the {palmerpenguins} R package"
    )
}

penguin_counts <- penguins |>
  filter(!is.na(sex)) |>
  mutate(year = as.character(year)) |>
  group_by(species, island, sex, year) |>
  summarise(n = n(), .groups = "drop")

penguin_counts_wider <- penguin_counts |>
  pivot_wider(
    names_from = c(species, sex),
    values_from = n
  ) |>
  # Make missing numbers (NAs) into zero
  mutate(across(.cols = -(1:2), .fns = ~ replace_na(., replace = 0))) |>
  arrange(island, year)

desired_colnames <- colnames(penguin_counts_wider) |> 
  str_remove('(Adelie|Gentoo|Chinstrap)_') |> 
  str_to_title() |> 
  set_names(nm = colnames(penguin_counts_wider))

penguin_counts_wider |>
  mutate(across(.cols = -(1:2), ~ if_else(. == 0, NA_integer_, .))) |>
  mutate(
    island = as.character(island),
    year = as.numeric(year),
    island = paste0("Island: ", island)
  ) |>
  gt(groupname_col = "island", rowname_col = "year") |>
  cols_label(.list = desired_colnames) |>
  spanners_and_header() |>
  sub_missing(missing_text = "-") |>
  summary_rows(
    groups = TRUE,
    fns = list(
      "Maximum" = ~ max(.),
      "Total" = ~ sum(.)
    ),
    formatter = fmt_number,
    decimals = 0,
    missing_text = "-"
  ) |>
  tab_options(
    data_row.padding = px(2),
    summary_row.padding = px(3), # A bit more padding for summaries
    row_group.padding = px(4) # And even more for our groups
  ) |>
  opt_stylize(style = 6, color = "gray")
```

This should give a nice fancy table and it does in latest 1.5 prerelease, but no more on main. On main, it is no table in the doc without any error or warning. Table is silently not included.

1.5.47 main

image

image

Not great for 1.5 release 😞

Let's find out what caused this ! I wondered if my environment is broken somehow... 😭

because I also see during typst rendering this

error: the argument '--v8-flags[=<v8-flags>...]' cannot be used multiple times

Usage: deno run [OPTIONS] [SCRIPT_ARG]...

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtablesIssues with Tables including the gt integrationtypst

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions