plotly / plotly/plotly.R

Provide a more general method for saving HTML

Open
#1,000 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
R
Stars
2.7k
Forks
641
PR merge metrics
No merged PRs in 30d

Description

Users shouldn't have to remember when to do htmlwidgets::saveWidget() vs htmltools::save_html() and the subtle differences between them.

Moreover, I want a way to save HTML tags without all the fuss of htmltools::save_html(), and I'm tired of waiting for https://github.com/rstudio/htmltools/issues/73

save_html <- function(x, file, selfcontained = TRUE, libdir = NULL, background = "white", knitrOptions = list()) {

  save_fun <- if (inherits(x, "htmlwidget")) {
    htmlwidgets::saveWidget
  } else if (inherits(x, "shiny.tag")) {
     save_tags
  } else { 
    stop("x must be an htmlwidget or an HTML tag list", call. = FALSE)
  }
    
  save_fun(x, file, selfcontained, libdir, background, knitrOptions)
}

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.

Research direction

Start by comparing htmlwidgets::saveWidget() with htmltools::save_html() and review the proposed save_html() wrapper, including its htmlwidget and shiny.tag cases. Done means one general saving method handles both supported input types and the listed options without requiring users to choose between the existing functions.

Written by the indexing model from the issue text.

Assessment

Tech stack
html, r
Domain
web-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.