ipython-contrib / jupyter_contrib_nbextensions

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

Table of contents should include headers in generated HTML #1594

Open e-dorigatti opened 2 years ago

e-dorigatti commented 2 years ago

It is possible to add arbitrary HTML to cell outputs via:

from IPython.core.display import display, HTML
display(HTML('<h2 id="aheader">hello!</h2>'))

These headers are added automatically to the TOC sidebar in jupyter lab, but are not in the TOC of exported HTML documents. It would be very convenient if they did!

A possible way of doing this is to change the selector here to include HTML output cells which have class .output_html:

all_headers = $('.text_cell_render,.output_html').find('[id]:header:not(:has(.tocSkip))');