How to export standalone (HTML) Jupyter notebook with TOC and collapsible headers

Viewed 973

I am using Jupyter notebooks to create interactive web reports for my job. Reports are fairly extense, so I would like to setup a TOC for easier navigation. I am aware of the extension that exists for this matter, but I would also like to have collapsible header synchronized with my TOC. All works great when running the notebook locally, but when exporting to HTML I have to choose between collapsible headings or TOC. Note: To export the notebooks I am using the jupyter nbconvert --to html_ch Untitled.ipynb for collapsible headings and jupyter nbconvert --to html_toc Untitled.ipynb for TOC.

Does anybody know if it is possible to "combine" both exporters and if it is, how?

1 Answers

This is verbatim from here. It is not possible to use multiple exporters at a time. But you could get the desired effect

jupyter nbconvert --to html_embed --template toc2 FILE

Otherwise, if what you want/need is to keep image files in the html (html_toc extracts the image since the extractPostprocesor is enabled in toc2.py -- may not be a good idea after all), you can issue

jupyter nbconvert --to html_toc --ExtractOutputPreprocessor.enabled=False FILE

The second one should work.

Related