@@ -41,7 +41,7 @@ knit_print.plotly <- function(x, options, ...) {
4141# ' @export
4242print.offline <- function (x , ... ) {
4343 off <- offline_bundle(jq = TRUE )
44- plotlyjs <- readChar(off , file.info(off )$ size )
44+ plotlyjs <- readChar(off , file.info(off )$ size , useBytes = TRUE )
4545 html <- sprintf(
4646 ' <!DOCTYPE html><html lang="en">
4747 <head>
@@ -62,7 +62,7 @@ print.offline <- function(x, ...) {
6262 }
6363 index <- file.path(d , " index.html" )
6464 res <- writeLines(html , index )
65- if (! is.null (x $ viewer )) x $ viewer(index )
65+ if (is.function (x $ viewer )) x $ viewer(index )
6666}
6767
6868# ' Embed a plotly iframe into an R markdown document via \code{knit_print}
@@ -80,7 +80,7 @@ knit_print.offline <- function(x, options, ...) {
8080 # if this is the first plot, place bundle just before the plot
8181 if (length(knitr :: knit_meta(class = " plotly" , clean = FALSE )) == 0 ) {
8282 off <- offline_bundle(jq = TRUE )
83- b <- readChar(off , file.info(off )$ size )
83+ b <- readChar(off , file.info(off )$ size , useBytes = TRUE )
8484 p <- paste0(
8585 sprintf(' <script type="text/javascript">%s</script>' , b ),
8686 p
0 commit comments