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

Download embedded HTML from the Menu #1039

Merged
merged 16 commits into from
Aug 12, 2017
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Type: Jupyter Notebook Extension
Compatibility: 5.x
Main: main.js
Name: Export Embedded HTML
Description: Export to HTML with images embedded
Icon: icon.png
Link: readme.md
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// toggle display of all code cells' inputs

define([
'jquery',
'base/js/namespace',
'base/js/events'
], function(
$,
Jupyter,
events
) {
"use strict";

function initialize () {
}

var load_ipython_extension = function() {

var v = Jupyter.version.split(".")
if(Number(v[0])*10+ Number(v[1]) < 51)
{
console.log('Notebook version 5.1.0 or higher required for this extension')
return
}

/* Add an entry in the download menu */
var dwm = $("#download_menu")
var downloadEntry = $('<li id="download_html_embed"><a href="#">HTML Embedded (.html)</a></li>')
dwm.append(downloadEntry)
downloadEntry.click(function () {
Jupyter.menubar._nbconvert('html_embed', true);
});

/* Add also a Button, currently disabled */
/*
Jupyter.toolbar.add_buttons_group([{
id : 'export_embeddedhtml',
label : 'Embedded HTML Export',
icon : 'fa-save',
callback : function() {
Jupyter.menubar._nbconvert('html_embed', true);
}
}]);
*/
if (Jupyter.notebook !== undefined && Jupyter.notebook._fully_loaded) {
// notebook_loaded.Notebook event has already happened
initialize();
}
events.on('notebook_loaded.Notebook', initialize);
};

return {
load_ipython_extension : load_ipython_extension
};
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Export HTML With Embedded Images
================================
This extension allows exporting an embedded HTML by an additional download option in File -> Download -> HTML Embedded, (works like: jupyter nbconvert --to html_embed notebook.ipynb)

**Note**: This extension can so far only successfully read relative images paths in the markdown cells (e.g. `![](graphics/pic.png)`) when jupyter is started in the same folder (working directory) where the relative paths can be resolved!