Hello. I have stumbled upon the issue with code cells rendering.
Describe the bug
When I render one of my github notebooks, code cells are empty. It works well when I render previous notebooks, but the last one doesn't want to work as expected. I checked the notebook code, but it looks good (not differ significantly from other notebooks). It is not rather the jupyter notebook issue because I found the solution to this problem, but it is not permanent. I tried to refresh the notebook with ?flush_cache=true but it didn't help.
Thank you for looking into this so thoroughly! This already gives a lot of hints about what might be done to fix the issue.
To confirm, when running Jupyter Notebook locally (not JupyterLab), does the issue not occur? (i.e. from the command line jupyter notebook instead of jupyter lab?)
What NBViewer does is import all of the CSS files from the Jupyter Notebook package and then build them to create the notebook.css file, so this might be an issue with the CSS files from the Jupyter Notebook, or it might be an issue with how NBViewer builds those CSS files.
So if it's not possible to reproduce the issue using the standalone Jupyter Notebook, that seems to suggest that the issue will then be with NBConvert or with NBViewer itself. On the other hand, if it does show up in Jupyter Notebook, then that will suggest something different.
The issue doesn't occur when running Jupyter Notebook locally. The same notebook that caused problems with rendering mentioned earlier is displayed properly by Jupyter Notebook on my local machine, so that might suggest that Jupyter Notebook creates HTML and CSS files correctly. Blank cells appear only when rendering on https://nbviewer.jupyter.org/, but I also reproduced this issue locally using $ jupyter nbconvert notebook.ipynb. It turned out that empty code cells were caused by one <div> tag that wasn't closed properly in the preceding markdown cell. It seems that nbconvert is sensitive particularly to not enclosed <div> tags (using different tags didn't induce the same problem) and makes that the display: none; rule is applied, which cause that all following code cells are blank. It is a bit confusing behavior, that one tag from a markdown affects all code cells, maybe the display: none; rule should be disabled by default?
I think that this issue can be closed. Thank you for your help.
Thank you for the status update! You might consider opening this with NBConvert, since based on your description it seems like something they might be interested in taking a look at.
Hello. I have stumbled upon the issue with code cells rendering.
Describe the bug When I render one of my github notebooks, code cells are empty. It works well when I render previous notebooks, but the last one doesn't want to work as expected. I checked the notebook code, but it looks good (not differ significantly from other notebooks). It is not rather the jupyter notebook issue because I found the solution to this problem, but it is not permanent. I tried to refresh the notebook with
?flush_cache=true
but it didn't help.To Reproduce Steps to reproduce the behavior:
Screenshots Code cells are blank:
Inspect the code cell and go to
I figured out that the reason why the code cells are empty is due to that the notebook.css file contains the following lines:
If we remove the
display: none
line then the code is displayed properly.Why in that case the css file contains such setting? How to force the nbviewer to get rid of that css rule permanently?
Desktop:
Thank you for looking into this so thoroughly! This already gives a lot of hints about what might be done to fix the issue.
To confirm, when running Jupyter Notebook locally (not JupyterLab), does the issue not occur? (i.e. from the command line
jupyter notebook
instead ofjupyter lab
?)What NBViewer does is import all of the CSS files from the Jupyter Notebook package and then build them to create the
notebook.css
file, so this might be an issue with the CSS files from the Jupyter Notebook, or it might be an issue with how NBViewer builds those CSS files.So if it's not possible to reproduce the issue using the standalone Jupyter Notebook, that seems to suggest that the issue will then be with NBConvert or with NBViewer itself. On the other hand, if it does show up in Jupyter Notebook, then that will suggest something different.
@radoslawkrolikowski This seems to be the relevant line in the notebook CSS, at least based on the image you've attached:
https://github.com/jupyter/notebook/blob/b8b66332e2023e83d2ee04f83d8814f567e01a4e/notebook/static/notebook/less/textcell.less#L53
So this might be an issue with the Notebook.
For the record I am able to reproduce your issue on Google Chrome and Mac OS X.
The issue doesn't occur when running Jupyter Notebook locally. The same notebook that caused problems with rendering mentioned earlier is displayed properly by Jupyter Notebook on my local machine, so that might suggest that Jupyter Notebook creates HTML and CSS files correctly. Blank cells appear only when rendering on https://nbviewer.jupyter.org/, but I also reproduced this issue locally using
$ jupyter nbconvert notebook.ipynb
. It turned out that empty code cells were caused by one<div>
tag that wasn't closed properly in the preceding markdown cell. It seems thatnbconvert
is sensitive particularly to not enclosed<div>
tags (using different tags didn't induce the same problem) and makes that thedisplay: none;
rule is applied, which cause that all following code cells are blank. It is a bit confusing behavior, that one tag from a markdown affects all code cells, maybe thedisplay: none;
rule should be disabled by default?I think that this issue can be closed. Thank you for your help.
Thank you for the status update! You might consider opening this with NBConvert, since based on your description it seems like something they might be interested in taking a look at.