Skip to content

Commit

Permalink
Merge pull request ramnathv#298 from ramnathv/joe/bugfix/save-widget-…
Browse files Browse the repository at this point in the history
…background

Fix ramnathv#297: Setting background in saveWidget() is broken
  • Loading branch information
jjallaire authored Jan 24, 2018
2 parents fd4f976 + fd37e0c commit 03b6d9b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: htmlwidgets
Type: Package
Title: HTML Widgets for R
Version: 1.0
Version: 1.1
Authors@R: c(
person("Ramnath", "Vaidyanathan", role = c("aut", "cph")),
person("Yihui", "Xie", role = c("aut")),
Expand Down
7 changes: 7 additions & 0 deletions R/savewidget.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ saveWidget <- function(widget, file, selfcontained = TRUE, libdir = NULL,
background = "white", title = class(widget)[[1]],
knitrOptions = list()) {

# Transform #RRGGBB/#RRGGBBAA colors to rgba(r,g,b,a) form, because the
# pound sign interferes with pandoc processing
if (grepl("^#", background, perl = TRUE)) {
bgcol <- col2rgb(background, alpha = TRUE)
background <- sprintf("rgba(%d,%d,%d,%f)", bgcol[1,1], bgcol[2,1], bgcol[3,1], bgcol[4,1]/255)
}

# convert to HTML tags
html <- toHTML(widget, standalone = TRUE, knitrOptions = knitrOptions)

Expand Down
14 changes: 14 additions & 0 deletions inst/NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
htmlwidgets 1.1
-----------------------------------------------------------------------

* The saveWidget's background parameter could not process hex color
codes, due to changes introduced in htmlwidgets 1.0. (#297)


htmlwidgets 1.0
-----------------------------------------------------------------------

* Fix issues with self-contained mode when used with new versions of
pandoc. (#289)


htmlwidgets 0.9
-----------------------------------------------------------------------

Expand Down

0 comments on commit 03b6d9b

Please sign in to comment.