ipython_notebook_goodies
ipython_notebook_goodies copied to clipboard
Port to jupyterlab?
Unfortunately this doesn't work out of the box with jupyterlab (see https://github.com/jupyterlab/jupyterlab/issues/1818).
I managed go get the script to load by first loading jquery like this
%%javascript
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://code.jquery.com/jquery-3.4.1.min.js';
document.head.appendChild(script);
And then
%%javascript $.getScript('https://kmahelona.github.io/ipython_notebook_goodies/ipython_notebook_toc.js')
However the TOC is not correct. The markdown headers from all the notebooks I have open (in different tabs) are meshed together.
Haven't had time to debug it properly.. maybe you have some ideas though :-)
You mean that your ToC on one webpage/tab contains items from other notebooks you have open in other tabs? That’s bizarre. I haven’t used the notebook for years - before it was jupyter - so I’m not sure what’s going on.
Maybe modifying the selector? Currently it’s set to ‘:header’.
https://github.com/kmahelona/ipython_notebook_goodies/blob/aaefb28c21c12237a10f9bd7dff9723feb084391/ipython_notebook_toc.js#L22
Also it would be easy to update the code to not use JQuery.
Bringing up an old thread, but just wanted to comment that the above solution posted by @lambdamusic has worked well for me.
I did get the same issue that they noted (headers from all the notebooks I have open (in different tabs) are meshed together), or something similar - but I found that when I exported the notebook as .html this issue was not there - it only contained the headings from my notebook. For me, this is the desired function so I'm happy with it.
I would recommend moving @lambdamusic 's solution into the README file with a notice to Jupyter Lab users, as this getting more popular than Notebook.