Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[toc2] Add a 'download as HTML with toc' for Jupyter >= 5.1 #1182

Merged
merged 1 commit into from
Dec 22, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/jupyter_contrib_nbextensions/nbextensions/toc2/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,21 @@ define([
var table_of_contents = toc2.table_of_contents;
var toggle_toc = toc2.toggle_toc;

// extra download as html with toc menu (needs IPython kernel)
// extra download as html with toc menu
function addSaveAsWithToc() {

if (parseFloat(Jupyter.version.substr(0, 3)) >= 5.1) {
if ($("#download_html_toc").length === 0) {
/* Add an entry in the download menu */
var dwm = $("#download_menu")
var downloadEntry = $('<li id="download_html_toc"><a href="#">HTML with toc (.html)</a></li>')
$("#download_html").after(downloadEntry)
downloadEntry.click(function () {
Jupyter.menubar._nbconvert('html_toc', true);
});
}
}
else { /* Add a "save a" menu entry for pre 5.1 versions (needs python kernel) */
if (IPython.notebook.metadata.kernelspec.language == 'python') {
if ($('#save_html_with_toc').length == 0) {
$('#save_checkpoint').after("<li id='save_html_with_toc'/>")
Expand All @@ -47,6 +60,7 @@ define([
else {
$('#save_html_with_toc').remove()
}
}
}

var toc_button = function(cfg) {
Expand Down