quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.89k stars 321 forks source link

Can't navigate to revealjs slides if the slide title is the same as column label from gt / great_tables output #10256

Open mine-cetinkaya-rundel opened 3 months ago

mine-cetinkaya-rundel commented 3 months ago

Quarto version 1.5.37

If a slide has the same title as the column label of a gt/great_tables table, it's impossible to navigate to that slide. I can't replicate this issue with other table packages I've tried (e.g., knitr or itables).

R / gt

---
title: title
format: revealjs
---

## great_tables

```{r}
library(gt)
gt(head(gtcars, n = 10))

mfr

some text

model

1 + 1

something else

more text


https://github.com/quarto-dev/quarto-cli/assets/5965649/5e366f6d-ebbd-4501-a5c5-56a98126639e

## Python / great_tables

````markdown
---
title: title
format: revealjs
---

## great_tables

```{python}
from great_tables import GT
from great_tables.data import gtcars

(
    GT(gtcars.head(n = 10))
)

mfr

some text

model

1 + 1

something else

more text



https://github.com/quarto-dev/quarto-cli/assets/5965649/f3f1e82c-23ef-4b13-9395-89a670afd449
cderv commented 3 months ago

gt (and great_tables) are setting id for each column in a table. Example

<th id="mfr" class="gt_col_heading gt_columns_bottom_border gt_left" data-quarto-table-cell-role="th" scope="col">mfr</th>

That is quite surprising as in a HTML document, an id should be unique, so it could create conflict in other usage than in Quarto.

For Quarto, this is a problem as by default, slide title are used for navigation, using title slide as hash in url.

Current workaround

I don't know exactly if Quarto should do something here, like detect gt or great table is used, and so something.

It seems like gt or great_tables could just not set id when inside Quarto context, or used a prefix like gt-<colname> to avoid any conflict. I don't know what those ids are used for ... cc @rich-iannone