3

I am using Jupyter notebooks with jupyter-contrib-nbextensions and I can fold sections as well as code blocks in them. I want to know if there is a way to preserve the folding feature when the notebook is exported to html. Currently when I export to html, I can't fold anything. The notebook becomes cumbersome to handle if it's long, even if there's a table of contents. I'll appreciate any ideas in this regard. Thanks!

2 Answers2

2

Interesting need. I briefly looked into this. Looks like the nbextensions don't have that capability. I think there are perhaps two choices, both of which would require quite some work:

  • Take the html file and convert it to some form that would allow cascading style sheets and then manually implement folding
  • If you are looking to do this repeatedly and have the skills, then you could look at the nbextensions code and try to change it to make it fold

If you find any other options or solutions, post it here.

SanV
  • 855
  • 8
  • 16
1

According to the docs for the "Collapsible Headings"-extension in nbextensions, you should be able to export a foldable html-file by using the html_ch format:

jupyter nbconvert --to html_ch FILE.ipynb
Janus
  • 5,421
  • 2
  • 26
  • 37