File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
src/jupyter_contrib_nbextensions/nbextensions/toc2 Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -24,8 +24,21 @@ define([
24
24
var table_of_contents = toc2 . table_of_contents ;
25
25
var toggle_toc = toc2 . toggle_toc ;
26
26
27
- // extra download as html with toc menu (needs IPython kernel)
27
+ // extra download as html with toc menu
28
28
function addSaveAsWithToc ( ) {
29
+
30
+ if ( parseFloat ( Jupyter . version . substr ( 0 , 3 ) ) >= 5.1 ) {
31
+ if ( $ ( "#download_html_toc" ) . length === 0 ) {
32
+ /* Add an entry in the download menu */
33
+ var dwm = $ ( "#download_menu" )
34
+ var downloadEntry = $ ( '<li id="download_html_toc"><a href="#">HTML with toc (.html)</a></li>' )
35
+ $ ( "#download_html" ) . after ( downloadEntry )
36
+ downloadEntry . click ( function ( ) {
37
+ Jupyter . menubar . _nbconvert ( 'html_toc' , true ) ;
38
+ } ) ;
39
+ }
40
+ }
41
+ else { /* Add a "save a" menu entry for pre 5.1 versions (needs python kernel) */
29
42
if ( IPython . notebook . metadata . kernelspec . language == 'python' ) {
30
43
if ( $ ( '#save_html_with_toc' ) . length == 0 ) {
31
44
$ ( '#save_checkpoint' ) . after ( "<li id='save_html_with_toc'/>" )
@@ -47,6 +60,7 @@ define([
47
60
else {
48
61
$ ( '#save_html_with_toc' ) . remove ( )
49
62
}
63
+ }
50
64
}
51
65
52
66
var toc_button = function ( cfg ) {
You can’t perform that action at this time.
0 commit comments