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

EmbedHTMLExporter mangles html output #1467

Open jp68138743541 opened 4 years ago

jp68138743541 commented 4 years ago

I regularly use the EmbedHTMLExporter to generate reports including plotly graphics, but occasionally, the browser cannot render the report and displays only parts of it. Now I managed to create a reproducible example. The problem seems to be that the EmbedHTMLExporter stops the figure data suddenly, which breaks the html format. If I use the EmbedHTMLExporter on the report (see attached zip file), I get this file ending (last 200 characters): [...]:59.286626300", "2018-05-30 08:58:59.473826300", "2018-05-30 08:58:59.676626300", "2018-05-30 08:58:59.879426300", "2018-05-30 08</script></div></div></div></div></div></div></div></div></body></html> Using the default nbconverter, I get this output (again, only the last 200 characters): [...]><div class="inner_cell"> <div class="input_area"><div class=" highlight hl-ipython3"><pre><span></span> </pre></div> </div></div></div></div> </div> </div></body></html>

To make reproduction easier, I tested the script within the jupyter docker container. Just run docker pull jupyter/scipy-notebook and docker run -p 8888:8888 jupyter/scipy-notebook. Now you can access jupyter at http://127.0.0.1:8888. Upload the files from the attached zip file, run the first cell from setupAndConversion.ipynb in order to install the dependencies, execute the report.ipynb, save the notebook and execute the second and third cell from setupAndConversion.ipynb. That should give you the mangled output posted above.

report.zip

jp68138743541 commented 4 years ago

I have investigated the problem a bit further down the rabbit hole. It seems that this is a problem of lxml. If the call to replfunc is commented out, the problem still persists, which means that the calls to the lxml functions fromstring and tostring mess things up.