Skip to content

Use htmltools functions for htmlwidget notebook annotation - #1799

Merged
yihui merged 6 commits into
rstudio:masterfrom
cderv:html-unpreserve
Apr 20, 2020
Merged

yihui merged 6 commits into
rstudio:masterfrom
cderv:html-unpreserve

Conversation

@cderv

@cderv cderv commented Apr 18, 2020 •

Copy link
Copy Markdown
Collaborator

This fixes #1762

The issue was in the unpreserving html widget code for UFT8 special character encoded on two byte. (see #1762 (comment)).

Using the htmltools functions to deal with preserved code extraction seems now the way to do it.

I tried to add a test by simplifying the code I used to come up with the solution. Not sure if this is the simplest unit test. Also I added skip_on_cran() because the other test had this too ☺️

In addition, I think this could also have been resolved by making sure to use bytes Encoding before using substrings like in

rmarkdown/R/util.R

Lines 283 to 288 in 1c859f4

starts_with_bytes <- function(string, bytes) {
Encoding(string) <- Encoding(bytes) <- "bytes"
if (n_bytes(bytes) > n_bytes(string))
return(FALSE)
substring(string, 1, n_bytes(bytes)) == bytes
}

However, htmltools functions seemed dedicated to this usage.

@yihui yihui left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes perfect sense to use htmltools. Thanks!

@yihui
yihui merged commit 131cf02 into rstudio:master Apr 20, 2020
@cderv
cderv deleted the html-unpreserve branch April 20, 2020 19:59
@cderv
cderv restored the html-unpreserve branch July 15, 2020 19:56
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jan 12, 2021
@cderv
cderv deleted the html-unpreserve branch July 26, 2021 08:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

html notebook rendering error when ploting data with unicode chinese char in ggplotly

2 participants