quarto-dev / quarto-cli

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

HTML tables are no more rendered in PPTX output #9365

Closed cderv closed 6 months ago

cderv commented 7 months ago

Discussed in https://github.com/quarto-dev/quarto-cli/discussions/9363

Originally posted by **andresrcs** April 13, 2024 ### Description I used to be able to insert `gt` tables in PowerPoint presentations seamlessly but It has stopped working, here you can find a minimal reproducible example. If you render this code, it produces a presentation with no table in it. I'm using `quarto` version 1.4.553 that comes bundled with RStudio (daily build 2024.04.0 Build 693) ````qmd --- title: "Test" format: pptx editor: visual --- ```{r setup} library(gt) ``` ## Test Table ```{r} #|label: test iris %>% gt() %>% as_raw_html() ``` ````
cderv commented 7 months ago

This works in 1.3.450 but no more in 1.4.553 nor 1.5

---
title: "Tables"
format: 
  pptx: default
keep-md: true
---

# Test table

```{=html}
<table>
<thead>
  <tr>
    <th>Sepal.Length</th>
    <th>Sepal.Width</th>
  </tr>
</thead>
<tbody>
<tr>
  <td>5.1</td>
  <td>3.5</td>
</tr>
<tr>
  <td>4.9</td>
  <td>3.0</td>
</tr>
</tbody>
</table>


We document HTML tables are a way to create table for all output formats 
https://quarto.org/docs/authoring/tables.html#html-tables

I believe this is a regression 
cscheid commented 7 months ago

I wonder if what's going on here is that the PPTX writer only supports Pandoc's SimpleTable, and the tables that are coming from the HTML reader are the fancy kind.

cderv commented 6 months ago

So the issue is that Table in Divs is not working in pptx format in Pandoc

❯ quarto pandoc -t pptx -o test.pptx
# slide

::: {}

| Col1 | Col2 | Col3 |
|------|------|------|
| a    | a    | a    |
| a    | a    | a    |
| a    | a    | a    |

:::

^Z

And somehow with 1.4 we have some empty div around tables

This is the native representation we have with quarto render --to native

Pandoc
  Meta
    { unMeta =
        fromList [ ( "title" , MetaInlines [ Str "Tables" ] ) ]
    }
  [ Header
      1
      ( "test-table" , [] , [] )
      [ Str "Test" , Space , Str "table" ]
  , Div
      ( "" , [] , [] )
      [ Table
          ( "" , [] , [ ( "quarto-postprocess" , "true" ) ] )
          (Caption Nothing [])
          [ ( AlignDefault , ColWidthDefault )
          , ( AlignDefault , ColWidthDefault )
          ]
          (TableHead
             ( "" , [] , [] )
             [ Row
                 ( "" , [] , [] )
                 [ Cell
                     ( ""
                     , []
                     , [ ( "quarto-table-cell-role" , "th" ) ]
                     )
                     AlignDefault
                     (RowSpan 1)
                     (ColSpan 1)
                     [ Plain [ Str "Sepal.Length" ] ]
                 , Cell
                     ( ""
                     , []
                     , [ ( "quarto-table-cell-role" , "th" ) ]
                     )
                     AlignDefault
                     (RowSpan 1)
                     (ColSpan 1)
                     [ Plain [ Str "Sepal.Width" ] ]
                 ]
             ])
          [ TableBody
              ( "" , [] , [] )
              (RowHeadColumns 0)
              []
              [ Row
                  ( "" , [] , [] )
                  [ Cell
                      ( "" , [] , [] )
                      AlignDefault
                      (RowSpan 1)
                      (ColSpan 1)
                      [ Plain [ Str "5.1" ] ]
                  , Cell
                      ( "" , [] , [] )
                      AlignDefault
                      (RowSpan 1)
                      (ColSpan 1)
                      [ Plain [ Str "3.5" ] ]
                  ]
              , Row
                  ( "" , [] , [] )
                  [ Cell
                      ( "" , [] , [] )
                      AlignDefault
                      (RowSpan 1)
                      (ColSpan 1)
                      [ Plain [ Str "4.9" ] ]
                  , Cell
                      ( "" , [] , [] )
                      AlignDefault
                      (RowSpan 1)
                      (ColSpan 1)
                      [ Plain [ Str "3.0" ] ]
                  ]
              ]
          ]
          (TableFoot ( "" , [] , [] ) [])
      ]
  ]

It seems we just need to remove this div for powerpoint... 🤔

andresrcs commented 6 months ago

I have tested the fix using quarto 1.5.36 and it works in the sense that HTML tables are now displayed but they are getting inserted in the top right corner instead of in the "body" of the pptx layout as it was the case before. This implies manual post-processing of the presentation wich defeats the purpose of automation.

cderv commented 6 months ago

I have tested the fix using quarto 1.5.36 and it works in the sense that HTML tables are now displayed but they are getting inserted in the top right corner instead of in the "body" of the pptx layout as it was the case before.

You are referring to original example right ? https://github.com/quarto-dev/quarto-cli/issues/9365#issue-2241772677

Not the other one: https://github.com/quarto-dev/quarto-cli/issues/9365#issuecomment-2053755452

I believe you found another issue

andresrcs commented 6 months ago

Yes, I'm referring to the first example, but I have tested it with a real world pptx and the problem is the same.