jthomasmock / gtExtras

A Collection of Helper Functions for the gt Package.
https://jthomasmock.github.io/gtExtras/
Other
193 stars 26 forks source link

HTML output suitable for embedding #28

Closed dennisbrookner closed 2 years ago

dennisbrookner commented 2 years ago

Hey Thomas - love this package!

Issue

gtsave() HTML outputs are intended to be stand-alone HTML pages, and as such, are not suitable for being embedded into other HTML webpages. Specifically:

There may also be other formatting things I'm not thinking of!

Proposed solution

An optional argument to gtsave(), e.g. for_embedding = TRUE that provides an HTML chunk suitable for embedding rather than being its own page. I imagine that this is a pretty small change, and I'm happy to tackle it myself!

My current workaround

I recently used gt and gtExtras to make this table (https://puntalytics.github.io/gallery.html) on my website, using this github action (https://github.com/Puntalytics/Puntalytics.github.io/blob/master/.github/workflows/gttable.yml) and this script (https://github.com/Puntalytics/Puntalytics.github.io/blob/master/tables/tableworkflow.R). In this workflow, I just grep out the two problematic lines I mentioned above. It was an easy fix, but because this seems like it might be a common use case, I figure it makes sense to whip up a solution directly.

And of course, if there is already a way to address this in the package, my bad!

jthomasmock commented 2 years ago

Gotcha! Good to hear it can embed in external sites - I'll explore this a bit more and come back to the FR.

jthomasmock commented 2 years ago

Ah I just realized you're wanting updates to gtsave() - that is a gt function, as such you should post that as a Feature Request/issue on the gt repo. Thanks!