hydrogen icon indicating copy to clipboard operation
hydrogen copied to clipboard

Export to HTML

Open pascalbrunner opened this issue 5 years ago • 5 comments

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)

pascalbrunner avatar Jan 10 '20 12:01 pascalbrunner

@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.

wadethestealth avatar Jan 10 '20 17:01 wadethestealth

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);
}

pascalbrunner avatar Jan 10 '20 22:01 pascalbrunner

@pascalbrunner Did you update the exportNoteBook function in export-notebook.js? I am trying to get it work but failed. Could you elaborate a bit more? Thanks!

ruzihao avatar Apr 03 '22 14:04 ruzihao

any updates?

Italosayan avatar Oct 18 '23 15:10 Italosayan

hi, i wonder if there's any instruciton on how to implement @pascalbrunner code! it seems super useful :) thanks!

matibilkis avatar Feb 08 '24 18:02 matibilkis