Hydrogen: Export to HTML

Created on 10 Jan 2020  路  2Comments  路  Source: nteract/hydrogen

Summary:
HTML Report export of Notebook

Motivation:
Sharing my Code and Markdown Comments with my Team

Alternatives:
Export to Jupyter Notebook, Import Jupyter Notebook, Export Jupyter Notebook as HTML.

Question:
Is there already a possibilty? I tried HTML export, but the Output of my Code is missing (and the format doesnt look nice, but that would be ok)

enhancement

Most helpful comment

I implemented a html export possibility for myself. Perhaps it also helps somebody or somebody can write a module out of it.

This way it exports the .ipynb and a .html with rendered output in Jupyters Notebook form.

I opened atom in developer mode and changed the export notebook to the following:
`` export default function exportNotebook() { // TODO: Refactor to use promises, this is a bit "nested". const saveNotebook = function(filename) { if (!filename) { return; } const ext = path.extname(filename) === "" ? ".ipynb" : ""; const fname =${filename}${ext}; writeFile(fname, stringifyNotebook(store.notebook), function(err, data) { if (err) { atom.notifications.addError("Error saving file", { detail: err.message }); } else { atom.notifications.addSuccess("Save successful", { detail:Saved notebook as ${fname} }); } const execSync = require('child_process').execSync; const output = execSync(jupyter nbconvert --execute --to html ${fname}`, { encoding: 'utf-8' });
console.log('Output was:n', output);
});
};
dialog.showSaveDialog(saveNotebook);
}

All 2 comments

@pascalbrunner there is currently only exporting to a .ipynb file, and this does not yet contain outputs (see #1503) also there is no export to any other format beside .ipynb however i briefly experimented in #1080 with pdf export.

I implemented a html export possibility for myself. Perhaps it also helps somebody or somebody can write a module out of it.

This way it exports the .ipynb and a .html with rendered output in Jupyters Notebook form.

I opened atom in developer mode and changed the export notebook to the following:
`` export default function exportNotebook() { // TODO: Refactor to use promises, this is a bit "nested". const saveNotebook = function(filename) { if (!filename) { return; } const ext = path.extname(filename) === "" ? ".ipynb" : ""; const fname =${filename}${ext}; writeFile(fname, stringifyNotebook(store.notebook), function(err, data) { if (err) { atom.notifications.addError("Error saving file", { detail: err.message }); } else { atom.notifications.addSuccess("Save successful", { detail:Saved notebook as ${fname} }); } const execSync = require('child_process').execSync; const output = execSync(jupyter nbconvert --execute --to html ${fname}`, { encoding: 'utf-8' });
console.log('Output was:n', output);
});
};
dialog.showSaveDialog(saveNotebook);
}

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DannyDannyDanny picture DannyDannyDanny  路  3Comments

wadethestealth picture wadethestealth  路  3Comments

ethan92429 picture ethan92429  路  3Comments

olegantonyan picture olegantonyan  路  3Comments

tobiasbj picture tobiasbj  路  4Comments