Giter Site home page Giter Site logo

nbviewer.js's Introduction

client side rendering of jupyter notebooks

tl;dr: Render Jupyter notebooks straight in the browser, without a back end converter. Can be used as a library.

I often want to read through my Jupyter notebooks, but I rarely have my Jupyter instances running in the right folders. I can't quite use the online nbviewer, because I don't have a public URL for these, so I resort to running dummy Jupyter instances or uploading my file as a one-time gist on Github (one I have to delete thereafter). One last possibility is nbconvert in the command line.

I thought it could be easier and more lightweight. So I hacked together this client side rendering of Jupyter notebooks. All you need is a browser that renders an HTML file (dependent on some JavaScript and CSS, both of which can be inlined). You simply drag and drop an .ipynb file and it renders. It's rather fast and it supports most notebook features. I tried supporting the previous version (v3), since there are tons of examples in this version out there.

Try a live demo

Usage

There are two ways one can use this. You can use the library itself, there is just a single public method, you call nbv.render(data, target), where data is the JSON representation of your Jupyter notebook and target is the node where the notebook is to be rendered.

Or you can use the demo (or a local copy), which is just a simple wrapper of the library, with dropzones and other basic features. There is no data being transferred anywhere, so feel free to bookmark it and use it.

Two immediate use cases come to mind:

  1. In Mac OS, you can preview files and this system, Quick Look, supports plugins. It would be rather handy to have a notebook preview one keystroke away.
  2. Ever since GitHub introduced notebook rendering last year, Gitlab users have been requesting the same. Gitlab itself recently dropped Python as a dependency, so its reintroduction just for converting notebooks is rather unlikely. A browser-based solution like this could be a good substitute.

Tech details

It's rather simple at this point, all the DOM manipulation is written in vanilla JavaScript, Markdown rendering goes through marked.js, syntax highlighting is administered by Prism.js. The example implementation leverages a few goodies from modern web design, like File API or drag&drops, so a fairly modern browser is necessary.

Showcase

screencast

Contact

Drop me an email ([email protected]) or tweet at me (@pndrej) if you have any questions or suggestions. Contributions welcome.

nbviewer.js's People

Contributors

kokes avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.