great-tables icon indicating copy to clipboard operation
great-tables copied to clipboard

Wrap header rows in `<thead>`

Open cwickham opened this issue 1 year ago • 0 comments

Prework

Description

Header rows should always be wrapped in <thead>. In particular, this will mean tables output to Typst that break over pages get the header rows repeated on each page.

Reproducible example

Consider the following example:

from great_tables import GT, md, html
from great_tables.data import islands

gt_tbl = GT(islands)
# Show the output table
gt_tbl

This results in the following (partial) HTML:

<table class="gt_table" data-quarto-disable-processing="false" data-quarto-bootstrap="false">

<tr class="gt_col_headings">
  <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="name">name</th>
  <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1" scope="col" id="size">size</th>
</tr>
<tbody class="gt_table_body">
...

If this table is used in Quarto with format: typst and is allowed to break over pages, the header rows are not repeated on the second page:

Screenshot 2024-07-18 at 11 01 42 AM
QMD
---
title: "Untitled"
format: typst
keep-md: true
---

```{=typst}
#show figure: set block(breakable: true)
```
```{python}
from great_tables import GT, md, html
from great_tables.data import islands

gt_tbl = GT(islands)
# Show the output table
gt_tbl
```

Expected result

E.g. in gt the header rows are nested inside <thead>,

<table class="gt_table" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
  <thead>
    <tr class="gt_col_headings">
      <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="name">name</th>
      <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1" scope="col" id="size">size</th>
    </tr>
  </thead>
  <tbody class="gt_table_body">

Then the header rows are repeated on the second page:

Screenshot 2024-07-18 at 11 05 32 AM

Development environment

  • Operating System: macOS Sonoma 14.4
  • great_tables Version: 0.10.0
  • Quarto: dev version

cwickham avatar Jul 18 '24 18:07 cwickham