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

Export to HTML #1858

Open
pascalbrunner opened this issue Jan 10, 2020 · 5 comments
Open

Export to HTML #1858

pascalbrunner opened this issue Jan 10, 2020 · 5 comments
Labels
enhancement 🌟 New feature ideas

Comments

@pascalbrunner
Copy link

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 pascalbrunner added the enhancement 🌟 New feature ideas label Jan 10, 2020
@wadethestealth
Copy link
Member

@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 wadethestealth changed the title HTML report export of Hydrogen Notebook Export to HTML Jan 10, 2020
@pascalbrunner
Copy link
Author

pascalbrunner commented Jan 10, 2020

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

@ruzihao
Copy link

ruzihao commented Apr 3, 2022

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

@Italosayan
Copy link

any updates?

@matibilkis
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 🌟 New feature ideas
Projects
None yet
Development

No branches or pull requests

5 participants