File tree Expand file tree Collapse file tree 2 files changed +24
-28
lines changed
src/jupyter_contrib_nbextensions/nbextensions/toc2 Expand file tree Collapse file tree 2 files changed +24
-28
lines changed Original file line number Diff line number Diff line change @@ -116,6 +116,30 @@ define([
116
116
return cfg ;
117
117
}
118
118
119
+ // extra download as html with toc menu (needs IPython kernel)
120
+ function addSaveAsWithToc ( ) {
121
+ if ( IPython . notebook . metadata . kernelspec . language == 'python' ) {
122
+ if ( $ ( '#save_html_with_toc' ) . length == 0 ) {
123
+ $ ( '#save_checkpoint' ) . after ( "<li id='save_html_with_toc'/>" )
124
+ $ ( '#save_html_with_toc' )
125
+ . append ( $ ( '<a/>' ) . text ( 'Save as HTML (with toc)' ) . attr ( "href" , "#" ) )
126
+ . on ( 'click' , function ( evt ) {
127
+ if ( IPython . notebook . metadata . kernelspec . language == 'python' ) {
128
+ var code = "!jupyter nbconvert '" + IPython . notebook . notebook_name + "' --template toc2" ;
129
+ console . log ( '[toc2] running:' , code ) ;
130
+ IPython . notebook . kernel . execute ( code ) ;
131
+ }
132
+ else {
133
+ alert ( 'Sorry; this only works with a IPython kernel' ) ;
134
+ $ ( '#save_html_with_toc' ) . remove ( ) ;
135
+ }
136
+ } ) ;
137
+ }
138
+ }
139
+ else {
140
+ $ ( '#save_html_with_toc' ) . remove ( )
141
+ }
142
+ }
119
143
120
144
121
145
Original file line number Diff line number Diff line change @@ -110,34 +110,6 @@ function highlight_toc_item(evt, data) {
110
110
}
111
111
}
112
112
113
-
114
- // extra download as html with toc menu (needs IPython kernel)
115
- function addSaveAsWithToc ( ) {
116
- var saveAsWithToc = $ ( '#save_html_with_toc' ) . length == 0
117
- var IPythonKernel = IPython . notebook . metadata . kernelspec . language == "python"
118
- if ( IPythonKernel ) {
119
- if ( $ ( '#save_html_with_toc' ) . length == 0 ) {
120
- $ ( '#save_checkpoint' ) . after ( "<li id='save_html_with_toc'/>" )
121
- $ ( '#save_html_with_toc' ) . append ( $ ( '<a/>' ) . text ( 'Save as HTML (with toc)' ) . attr ( "href" , "#" ) )
122
- $ ( '#save_html_with_toc' ) . click ( function ( ) {
123
- var IPythonKernel = IPython . notebook . metadata . kernelspec . language == "python"
124
- if ( IPythonKernel ) {
125
- var code = "!jupyter nbconvert '" + IPython . notebook . notebook_name + "' --template toc2"
126
- console . log ( code )
127
- IPython . notebook . kernel . execute ( code )
128
- } else {
129
- alert ( "Sorry; this only works with a IPython kernel" ) ;
130
- $ ( '#save_html_with_toc' ) . remove ( ) ;
131
- }
132
- } )
133
- }
134
- } else {
135
- if ( $ ( '#save_html_with_toc' ) . length > 0 ) $ ( '#save_html_with_toc' ) . remove ( )
136
- }
137
- }
138
-
139
-
140
-
141
113
var create_navigate_menu = function ( callback ) {
142
114
$ ( '#kernel_menu' ) . parent ( ) . after ( '<li id="Navigate"/>' )
143
115
$ ( '#Navigate' ) . addClass ( 'dropdown' ) . append ( $ ( '<a/>' ) . attr ( 'href' , '#' ) . attr ( 'id' , 'Navigate_sub' ) )
You can’t perform that action at this time.
0 commit comments