How to render tinytable styled HTML tables in pkgdown examples?

Open
#2,964 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
r
Domain
documentation

Research direction

Reproduce the behavior with pkgdown::build_site() using the tinytable examples from VisCollin's R/tt.colldiag.R, and compare the rendered output with the RStudio Viewer result. Review the linked tinytable issue and the attempted knitr::is_html_output() and print(output = "html") approaches; done means pkgdown examples preserve the styled HTML tables instead of showing plain text tables.

Written by the indexing model from the issue text.

Description

I filed this question as an issue for tinytable: https://github.com/vincentarelbundock/tinytable/issues/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

Dominant language
R
Stars
775
Forks
355
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from r-lib/pkgdown

All issues in r-lib/pkgdown

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.