Open cderv opened 10 months ago
To be clear, the intermediate .md here has zero width:
<table class="gt_table" style="-webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; display: table; border-collapse: collapse; line-height: normal; margin-left: auto; margin-right: auto; color: #333333; font-size: 16px; font-weight: normal; font-style: normal; background-color: #FFFFFF; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; table-layout: fixed; width: 0px;" data-quarto-disable-processing="false" data-quarto-bootstrap="false" width="0" bgcolor="#FFFFFF">
So I don't know what Quarto is supposed to be doing. I think this is on GT...
What puzzled me as a sign of difference somewhere is that HTML rendering is working while revealjs is failing. So something is revealjs does not handle the table properly.
Also as disabling quarto processing fixes it too, it was a sign to me of something different in our processes between the format, or a conflict with revealjs.
The difference when comparing both html file is that
<table class="gt_table" style=
)revealjs
, style=
attribute in <table>
is kept for intermediate .md content (<table class="gt_table" data-quarto-postprocess="true" style=)
- meaning this width: 0
element style attribute applies I think. html
, this attributes is not set so (we get directly <table class="gt_table table table-sm table-striped small" data-quarto-postprocess="true" data-quarto-disable-processing=
) - only width = 0
as table attribute is present and it does not apply. width=0
is a deprecated attributes it seems and CSS width
should be preferred.
@rich-iannone I'll open an issue on gt maybe to understand why 0 width is set by gt ?
it was a sign to me of something different in our processes between the format
Found it:
For HTML format, in our processing for bootstrap we do remove the style
attribute. So this is why the issue does not show in format: html
Opening the issue in gt helped me understand: https://github.com/rstudio/gt/issues/1532#issuecomment-1888950615
---
title: "Test"
format:
html:
theme: pandoc
keep-md: true
---
## Toto
```{r}
library(magrittr)
library(gt)
iris %>%
gt() %>%
cols_width(
"Sepal.Length" ~ px(300),
everything() ~ px(50)
) %>%
as_raw_html()
No bootstrap example with Quarto table processing
When we do the quarto processing, we don't keep the [`<colgroup>`](https://developer.mozilla.org/fr/docs/Web/HTML/Element/colgroup) within the table
````html
<table class="gt_table" style="-webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; display: table; border-collapse: collapse; line-height: normal; margin-left: auto; margin-right: auto; color: #333333; font-size: 16px; font-weight: normal; font-style: normal; background-color: #FFFFFF; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; table-layout: fixed; width: 0px;" data-quarto-disable-processing="false" data-quarto-bootstrap="false" width="0" bgcolor="#FFFFFF">
<colgroup>
<col style="width:300px;">
<col style="width:50px;">
<col style="width:50px;">
<col style="width:50px;">
<col style="width:50px;">
</colgroup>
<thead style="border-style: none;">
The width:0px
is set when column width are opt in by user (with cols_width
). In that case, the overall width is set by <colgroup>
total column width.
As Quarto Table processing does not keep it, the not removed width:0px
applies...
I think the gt issue is still valid (maybe opt out quarto processing when cols_width
is used ?)
but still maybe Quarto Table processing should adapt...
weren't the <colgroup>
supposed to be kept in the processing ?
I think this is about Pandoc not parsing colgroup
with a col
width
not in %
in % | in px | ||||||||||||
````powershell
> pandoc --from html --to html
|
````powershell
> pandoc --from html --to html
| ||||||||||||
AST is having ```` [ ( AlignDefault , ColWidth 0.2 ) , ( AlignDefault , ColWidth 0.4 ) , ( AlignDefault , ColWidth 0.4 ) ] ```` | ```` [ ( AlignDefault , ColWidthDefault ) , ( AlignDefault , ColWidthDefault ) , ( AlignDefault , ColWidthDefault ) ] ```` |
Looking our trace.json for the example shared with gt I get
colspecs:
- "(AlignRight, undefined)"
- "(AlignRight, undefined)"
- "(AlignRight, undefined)"
- "(AlignRight, undefined)"
- "(AlignCenter, undefined)"
so I think this is related to Pandoc not parsing units as px
I think this is the same problem I am having. Any GT table that contains any explicit column width assignment (e.g., cols_width(everything() ~ px(200)) does not render correctly in revealjs slides.
Removing the explicit assignment gives me a nicely formatted table with sensibly sized columns.
Yeah, pixels aren't handled by pandoc: https://github.com/quarto-dev/quarto-cli/issues/4316#issuecomment-1445420433
Tata