ramnathv / htmlwidgets

HTML Widgets for R
http://htmlwidgets.org
Other
792 stars 205 forks source link

Allow self-contained knitr_print #146

Open elbamos opened 9 years ago

elbamos commented 9 years ago

I'm trying to make it possible to embed htmlwidgets in a larger project using knitr. It seems that the knitr_print function for HTML widgets sets standalone=false, which makes it a lot harder to embed. Is it possible to change this so it pulls standalone from an option or from the chunk options? Or is FALSE hardcoded because that just won't work?

ramnathv commented 9 years ago

If you set self_contained: true in the YAML header of your rmarkdown document, it will automatically embed a standalone version of the widget in the output html.

elbamos commented 9 years ago

Right. But, I want to use knitr rather than rmarkdown.

On Aug 10, 2015, at 1:48 PM, Ramnath Vaidyanathan notifications@github.com wrote:

If you set self_contained: true in the YAML header of your rmarkdown document, it will automatically embed a standalone version of the widget in the output html.

— Reply to this email directly or view it on GitHub.

ramnathv commented 9 years ago

Can you provide a simple reproducible example to illustrate the issue at hand? If you are NOT using rmarkdown, what document are you trying to knit?

elbamos commented 9 years ago

I can try to later today. I'm writing an R plugin for Apache Zeppelin, which is a notebook project similar to Jupyter but oriented toward spark and other large data applications. (See my rinterpreter repo for slightly aged code.) I have to return an HTML fragment for insertion into the page. This is easier and faster to do with knitr than rmarkdown because knitr has lower overhead and I believe generally doesn't need to read and write temp files to disc. (I recognize that some of that benefit may be lost with htmlwidgets because it may need to call pandoc.) So I run knitr, then parse the HTML to extract the tags inside of , adding back any Githubissues.

  • Githubissues is a development platform for aggregating issues.