Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use htmltools functions for htmlwidget notebook annotation #1799

Merged
merged 6 commits into from
Apr 20, 2020

Conversation

cderv
Copy link
Collaborator

@cderv cderv commented Apr 18, 2020

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.

Copy link
Member

@yihui yihui left a comment

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