Skip to content

Commit dd47f82

Browse files
authored
Merge pull request #1039 from gabyx/download_embedded
Download embedded HTML from the Menu
2 parents 2a71b68 + 2eceed9 commit dd47f82

File tree

4 files changed

+69
-0
lines changed

4 files changed

+69
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Type: Jupyter Notebook Extension
2+
Compatibility: 5.x
3+
Main: main.js
4+
Name: Export Embedded HTML
5+
Description: Export to HTML with images embedded
6+
Icon: icon.png
7+
Link: readme.md
29.6 KB
Loading
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// toggle display of all code cells' inputs
2+
3+
define([
4+
'jquery',
5+
'base/js/namespace',
6+
'base/js/events'
7+
], function(
8+
$,
9+
Jupyter,
10+
events
11+
) {
12+
"use strict";
13+
14+
function initialize () {
15+
}
16+
17+
var load_ipython_extension = function() {
18+
19+
var v = Jupyter.version.split(".")
20+
if(Number(v[0])*10+ Number(v[1]) < 51)
21+
{
22+
console.log('Notebook version 5.1.0 or higher required for this extension')
23+
return
24+
}
25+
26+
/* Add an entry in the download menu */
27+
var dwm = $("#download_menu")
28+
var downloadEntry = $('<li id="download_html_embed"><a href="#">HTML Embedded (.html)</a></li>')
29+
dwm.append(downloadEntry)
30+
downloadEntry.click(function () {
31+
Jupyter.menubar._nbconvert('html_embed', true);
32+
});
33+
34+
/* Add also a Button, currently disabled */
35+
/*
36+
Jupyter.toolbar.add_buttons_group([{
37+
id : 'export_embeddedhtml',
38+
label : 'Embedded HTML Export',
39+
icon : 'fa-save',
40+
callback : function() {
41+
Jupyter.menubar._nbconvert('html_embed', true);
42+
}
43+
}]);
44+
*/
45+
if (Jupyter.notebook !== undefined && Jupyter.notebook._fully_loaded) {
46+
// notebook_loaded.Notebook event has already happened
47+
initialize();
48+
}
49+
events.on('notebook_loaded.Notebook', initialize);
50+
};
51+
52+
return {
53+
load_ipython_extension : load_ipython_extension
54+
};
55+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Export HTML With Embedded Images
2+
================================
3+
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)
4+
5+
**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!
6+
7+

0 commit comments

Comments
 (0)