How to use the nbdime/lib/patch.stringify function in nbdime

To help you get started, we’ve selected a few nbdime examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jupyter / nbdime / packages / webapp / src / app / merge.ts View on Github external
function downloadNotebook(notebook: nbformat.INotebookContent, filename: string) {
  let element = document.createElement('a');
  element.setAttribute(
    'href', 'data:text/plain;charset=utf-8,' +
    encodeURIComponent(stringify(notebook)));
  element.setAttribute('download', filename);

  element.style.display = 'none';
  document.body.appendChild(element);
  try {
    element.click();
  } finally {
    document.body.removeChild(element);
  }
}