ipython-contrib / jupyter_contrib_nbextensions

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

toc2 extension not compatible with nbconvert >= 6.0 #1602

Closed Sieboldianus closed 1 year ago

Sieboldianus commented 1 year ago

I sticked with nbconvert 5.6.1 as long as I could, to keep the nice toc2 in HTML converts of jupyter notebooks. However, nbconvert 5.6.1 is not compatible anymore with the latest Jupyter Lab. So I had to uograde to 'nbconvert=6.5.*' (conda-forge).

Unfortunately, the output html convert generated with html_toc produces js errors:

toc2.js:13 Uncaught TypeError: $ is not a function
    at toc2.js:13:23
    at Object.execCb (require.min.js:29:311)
    at $.check (require.min.js:18:423)
    at $.<anonymous> (require.min.js:23:9)
    at require.min.js:8:102
    at require.min.js:23:369
    at v (require.min.js:7:173)
    at $.emit (require.min.js:23:340)
    at $.check (require.min.js:19:403)
    at $.enable (require.min.js:23:238)

Al my tests solving this were not successful - would be very happy if someone could chime in.

This issue seems tightly related to #1533

Sieboldianus commented 1 year ago

Solved it:

Somehow, the order of these were switched:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js">
</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js"></script>

where it has to be:

<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>

I don't know where this is coming from, but at least I could confirm that toc2/html export + nbconvert=6.5.* + Jupyter Lab work. Will update here if I found a permanent solution..

[Edit]: Solved it - the new nbconvert index.html.j2 template had the wrong order of jquery and requirejs, see nbconvert/#1812. Posted a solution here.