pkgdown icon indicating copy to clipboard operation
pkgdown copied to clipboard

Feature Request: Display {gt} tables in the Examples section

Open ddsjoberg opened this issue 2 years ago • 3 comments

The uptick in packages utilizing gt to create beautiful tables has been significant over the last couple of years. https://gt.rstudio.com/

I would be amazing if pkgdown could somehow render/display these tables in the example section somehow.

One tricky bit, is that by default I believe the CSS from the parent site will override much of the stying within a gt table. I think each table would need to be "printed" utilizing the gt::as_raw_html() function, which will insert the default gt stylings and not allow global site CSS to take over any aspect of the table.

Thank you! 🍁

ddsjoberg avatar Jul 31 '23 17:07 ddsjoberg

+1, maybe like ggplot work, they could just be coerced to png somehow?

olivroy avatar Aug 16 '23 13:08 olivroy

That should probably be a gt feature request. It would need to define a pkgdown_print() method for whatever class it is returning.

dmurdoch avatar Aug 16 '23 14:08 dmurdoch

It seems that this script is used to generate examples for gt https://github.com/rstudio/gt/blob/master/scripts/generate_example_pngs.R

olivroy avatar Aug 16 '23 15:08 olivroy

From @rich-iannone, as_raw_html() will generate raw HTML suitable for direct embedding.

hadley avatar Apr 12 '24 13:04 hadley