Skip to content

How to render tinytable styled HTML tables in pkgdown examples? #2964

@friendly

Description

@friendly

I filed this question as an issue for tinytable: vincentarelbundock/tinytable#624
but perhaps the solution is more directly related to pkgdown.

Brief Description

When using tinytable in function examples that are rendered by pkgdown::build_site(), the tables appear as plain text/markdown tables rather than styled HTML tables with colors and backgrounds. This makes it difficult to showcase the visual styling capabilities of tinytable in package documentation.

Current Behavior

In my package VisCollin, I have a function tt.colldiag() that creates styled tables with background colors and variable font sizes:

https://github.com/friendly/VisCollin/blob/master/R/tt.colldiag.R

When I run an example in the RStudio console, this is what appears in the Viewer tab, which is what I want

Image

When I run pkgdown::build_site(), the examples execute but the output appears as plain text tables instead of rendered HTML with the styling preserved.

Image

What I've Tried

  1. Setting output option conditionally:

    if (knitr::is_html_output()) options(tinytable_print_output = "html")

    Result: No effect in pkgdown examples

  2. Explicitly calling print with output parameter:

    tt(cd) |> print(output = "html")

    Result: Error: x must be a data.frame`

  3. Checking tinytable's own pkgdown site:
    Even the tinytable documentation examples section appears to show only code, not rendered styled tables

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions