ipython-contrib / jupyter_contrib_nbextensions

A collection of various notebook extensions for Jupyter
http://jupyter-contrib-nbextensions.readthedocs.io/en/latest
Other
5.22k stars 806 forks source link

Using extensions with github nbviewer #878

Open Kevin-McIsaac opened 7 years ago

Kevin-McIsaac commented 7 years ago

As part of my workflow I push notebooks to a github repo. I then send a URL to a collaborator who can click on it to view/read the notebook. I understand that this is done using nbviewer which is run on rackspace as a service.

There are three extensions that I use to improve readability (Hide, TOC2 and Collapse Headings) that I'd like to work with the github nbviewer. Is there some way to make github nbviewer work with these?

jcb91 commented 7 years ago

the main problem with nbviewer is getting any custom css/js into the output. If it's an installation that you control, then you can use customized nbconvert commands, and it's relatively easy to inject whatever css/js is needed into the html output. However, for hosted installations like the rackspace nbviewer & github's nbviewer, the export command is fixed. This limit the options for adding css/js to including them in markdown, or as outputs of %%javascript cell magics. However, again, we run into problems because the markdown renderings are run through the google caja sanitizer, which strips style & script tags, and the javascript outputs are also implemented as untrusted, which makes them next to useless. This is unfortunate, but there isn't a huge number of ways around this, because the reason for these limitations (preventing malicious css/js from doing anything harmful) is solid, and so they're unlikely to be removed. If anyone has any alternative ideas, I'm all ears :ear: