├── .gitignore ├── LICENSE.txt ├── Makefile ├── README.md ├── bin └── cli-render.js ├── notebook.js ├── notebook.min.js ├── package-lock.json └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014, Jeremy Singer-Vine 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | notebook.min.js: notebook.js 2 | uglifyjs < notebook.js > $@ 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # notebook.js `v0.8.3` 2 | 3 | Notebook.js parses raw [Jupyter](http://jupyter.org/)/[IPython](http://ipython.org/) notebooks, and lets you render them as HTML. See a __[working demo here](https://jsvine.github.io/nbpreview/)__. 4 | 5 | ## Usage 6 | 7 | Notebook.js works in the browser and in Node.js. Usage is fairly straightforward. 8 | 9 | ### Browser Usage 10 | 11 | First, provide access to `nb` via a script tag: 12 | 13 | ```html 14 | 15 | ``` 16 | 17 | Then parse, render, and (perhaps) append: 18 | 19 | ``` 20 | var notebook = nb.parse(JSON.parse(raw_ipynb_json_string)); 21 | var rendered = notebook.render(); 22 | document.body.appendChild(rendered); 23 | ``` 24 | 25 | ### Node.js Usage 26 | 27 | To install: 28 | 29 | ```sh 30 | npm install notebookjs 31 | ``` 32 | 33 | Then parse, render, and write: 34 | 35 | ```js 36 | var fs = require("fs"); 37 | var nb = require("notebookjs"); 38 | var ipynb = JSON.parse(fs.readFileSync("path/to/notebook.ipynb")); 39 | var notebook = nb.parse(ipynb); 40 | console.log(notebook.render().outerHTML); 41 | ``` 42 | 43 | ## Markdown and ANSI-coloring 44 | 45 | On Node.js, notebook.js uses [marked](https://github.com/markedjs/marked) for Markdown rendering, and [ansi_up](https://github.com/drudru/ansi_up) for ANSI-coloring. 46 | 47 | The browser-based version does not, however, ship with those libraries, so you must `