cancel
Showing results for 
Search instead for 
Did you mean: 
Tasha_Biesinger
Adventurer

Knitr and Plotly HTML in Canvas Pages

Jump to solution

Hello wonderful Canvas Community! One of our faculty just asked this question and I'm hoping someone out there has a good answer:

I would like a smoother way to create pages using knitr in R, especially pages containing plotly graphs. What I'm doing now is knitting to HTML, then copying the resulting HTML into Canvas's HTML editor. This is clunky. Stuff doesn't translate right, and my graphs tend to disappear.

I was able to make more progress using the rcanvas package (https://github.com/daranzolin/rcanvas), but I still haven't found a streamlined way to get Canvas to accept a knitr-created html page with equations and figures.

Tags (3)
1 Solution

Accepted Solutions
jeremy_lykken
Community Member

Hi Tasha,

Not familiar with kniter, but the rendering issue most likely stems from how Canvas saves your external page markup copied into your page. In the time between saving a page and displaying your work, Canvas automatically lints your HTML and any inline CSS you have in your document which can alter how your content is displayed. The changes Canvas makes are based on the Canvas HTML Editor Whitelist and if a tag you use is not supported, it will replace it the best it can or in most cases simply omits it. A good example of tags you are prevented from using are most HTML semantic tag (e.g. nav, section) as well as buttons and form elements. Before uploading into Canvas, I suggest using your favorite IDE or text-editor to make your file "Canvas" compliant.

View solution in original post

3 Replies
ericwerth
Community Coach
Community Coach

Hi  @Tasha_Biesinger   This is a good question, but unfortunately one that I cannot answer.  However, I am going to share this with the Canvas Developers‌ user group in hopes that one of the creative folks there has insight that could be beneficial.  

All the best!

jeremy_lykken
Community Member

Hi Tasha,

Not familiar with kniter, but the rendering issue most likely stems from how Canvas saves your external page markup copied into your page. In the time between saving a page and displaying your work, Canvas automatically lints your HTML and any inline CSS you have in your document which can alter how your content is displayed. The changes Canvas makes are based on the Canvas HTML Editor Whitelist and if a tag you use is not supported, it will replace it the best it can or in most cases simply omits it. A good example of tags you are prevented from using are most HTML semantic tag (e.g. nav, section) as well as buttons and form elements. Before uploading into Canvas, I suggest using your favorite IDE or text-editor to make your file "Canvas" compliant.

View solution in original post

Thanks  @jeremy_lykken ! I'll see if the instructor will share some of their code with me to see if anything is getting stripped out or modified. This sounds like the most likely cause.