GithubHelp home page GithubHelp logo

h-plus-time / notebookjs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jsvine/notebookjs

0.0 2.0 1.0 153 KB

Render IPython/Jupyter notebooks on the fly, in the browser. (Or on the command line, if you'd like)

License: MIT License

Makefile 0.51% JavaScript 83.18% Jupyter Notebook 11.83% HTML 4.49%

notebookjs's Introduction

notebook.js v0.2.6

Notebook.js parses raw IPython/Jupyter notebooks, and lets you render them as HTML. See a working demo here.

Usage

Notebook.js works in the browser and in Node.js. Usage is fairly straightforward.

Browser Usage

First, provide access to nb via a script tag:

<script src="notebook.browser.min.js"></script>

Then parse, render, and (perhaps) append:

var notebook = nb.parse(raw_ipynb_json_string);
var rendered = notebook.render();
document.body.appendChild(rendered);

IO.js Usage

Note: To take advantage of jsdom's latest features/bugfixes, notebook.js now runs on io.js instead of Node.js.

To install:

npm install notebookjs

Then parse, render, and write:

var fs = require ("fs");
var nb = require("notebookjs");
var ipynb = JSON.parse(fs.readFileSync("path/to/notebook.ipynb"));
var notebook = nb.parse(ipynb);
console.log(notebook.render().outerHTML);

Markdown and ANSI-coloring

By default, notebook.js supports marked for Markdown rendering, and ansi_up for ANSI-coloring. It does not, however, ship with those libraries, so you must <script>-include or require them before initializing notebook.js.

To support other Markdown or ANSI-coloring engines, set nb.markdown and/or nb.ansi to functions that accept raw text and return rendered text.

Code-Highlighting

Notebook.js plays well with code-highlighting libraries. See NBPreview for an example of how to add support for your preferred highlighter.

MathJax

Notebook.js currently doesn't support all of MathJax's syntaxes (MathML, AsciiMath, LaTeX). It does however support a significant subset of LaTeX via KaTeX.

Styling Rendered Notebooks

The HTML rendered by notebook.js (intentionally) does not contain any styling. But each key element has fairly straightfoward CSS classes that make styling your notebooks a cinch. See NBPreview for an example implementation.

Thanks

Many thanks to the following users for catching bugs, fixing typos, and proposing useful features:

notebookjs's People

Contributors

jsvine avatar h-plus-time avatar

Watchers

James Cloos avatar  avatar

Forkers

montrin

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.