├── .eslintrc.json
├── .github
└── ISSUE_TEMPLATE
│ └── bug_report.md
├── .gitignore
├── .vscode
├── extensions.json
├── launch.json
└── settings.json
├── .vscodeignore
├── CHANGELOG.md
├── LICENSE
├── README.md
├── images
├── jupyter.png
└── sample.PNG
├── jsconfig.json
├── language-configuration.json
├── package-lock.json
├── package.json
├── src
├── extension.js
└── notebookjs
│ ├── .gitignore
│ ├── .npmignore
│ ├── LICENSE.txt
│ ├── Makefile
│ ├── README.md
│ ├── bin
│ └── cli-render.js
│ ├── bower.json
│ ├── mathjaxutils.js
│ ├── mathjaxutils.min.js
│ ├── notebook.js
│ ├── notebook.min.js
│ └── package.json
├── static
├── auto-render.min.js
├── custom.css
├── custom.js
├── fonts
│ ├── KaTeX_AMS-Regular.eot
│ ├── KaTeX_AMS-Regular.ttf
│ ├── KaTeX_AMS-Regular.woff
│ ├── KaTeX_AMS-Regular.woff2
│ ├── KaTeX_Caligraphic-Bold.eot
│ ├── KaTeX_Caligraphic-Bold.ttf
│ ├── KaTeX_Caligraphic-Bold.woff
│ ├── KaTeX_Caligraphic-Bold.woff2
│ ├── KaTeX_Caligraphic-Regular.eot
│ ├── KaTeX_Caligraphic-Regular.ttf
│ ├── KaTeX_Caligraphic-Regular.woff
│ ├── KaTeX_Caligraphic-Regular.woff2
│ ├── KaTeX_Fraktur-Bold.eot
│ ├── KaTeX_Fraktur-Bold.ttf
│ ├── KaTeX_Fraktur-Bold.woff
│ ├── KaTeX_Fraktur-Bold.woff2
│ ├── KaTeX_Fraktur-Regular.eot
│ ├── KaTeX_Fraktur-Regular.ttf
│ ├── KaTeX_Fraktur-Regular.woff
│ ├── KaTeX_Fraktur-Regular.woff2
│ ├── KaTeX_Main-Bold.eot
│ ├── KaTeX_Main-Bold.ttf
│ ├── KaTeX_Main-Bold.woff
│ ├── KaTeX_Main-Bold.woff2
│ ├── KaTeX_Main-Italic.eot
│ ├── KaTeX_Main-Italic.ttf
│ ├── KaTeX_Main-Italic.woff
│ ├── KaTeX_Main-Italic.woff2
│ ├── KaTeX_Main-Regular.eot
│ ├── KaTeX_Main-Regular.ttf
│ ├── KaTeX_Main-Regular.woff
│ ├── KaTeX_Main-Regular.woff2
│ ├── KaTeX_Math-BoldItalic.eot
│ ├── KaTeX_Math-BoldItalic.ttf
│ ├── KaTeX_Math-BoldItalic.woff
│ ├── KaTeX_Math-BoldItalic.woff2
│ ├── KaTeX_Math-Italic.eot
│ ├── KaTeX_Math-Italic.ttf
│ ├── KaTeX_Math-Italic.woff
│ ├── KaTeX_Math-Italic.woff2
│ ├── KaTeX_Math-Regular.eot
│ ├── KaTeX_Math-Regular.ttf
│ ├── KaTeX_Math-Regular.woff
│ ├── KaTeX_Math-Regular.woff2
│ ├── KaTeX_SansSerif-Bold.eot
│ ├── KaTeX_SansSerif-Bold.ttf
│ ├── KaTeX_SansSerif-Bold.woff
│ ├── KaTeX_SansSerif-Bold.woff2
│ ├── KaTeX_SansSerif-Italic.eot
│ ├── KaTeX_SansSerif-Italic.ttf
│ ├── KaTeX_SansSerif-Italic.woff
│ ├── KaTeX_SansSerif-Italic.woff2
│ ├── KaTeX_SansSerif-Regular.eot
│ ├── KaTeX_SansSerif-Regular.ttf
│ ├── KaTeX_SansSerif-Regular.woff
│ ├── KaTeX_SansSerif-Regular.woff2
│ ├── KaTeX_Script-Regular.eot
│ ├── KaTeX_Script-Regular.ttf
│ ├── KaTeX_Script-Regular.woff
│ ├── KaTeX_Script-Regular.woff2
│ ├── KaTeX_Size1-Regular.eot
│ ├── KaTeX_Size1-Regular.ttf
│ ├── KaTeX_Size1-Regular.woff
│ ├── KaTeX_Size1-Regular.woff2
│ ├── KaTeX_Size2-Regular.eot
│ ├── KaTeX_Size2-Regular.ttf
│ ├── KaTeX_Size2-Regular.woff
│ ├── KaTeX_Size2-Regular.woff2
│ ├── KaTeX_Size3-Regular.eot
│ ├── KaTeX_Size3-Regular.ttf
│ ├── KaTeX_Size3-Regular.woff
│ ├── KaTeX_Size3-Regular.woff2
│ ├── KaTeX_Size4-Regular.eot
│ ├── KaTeX_Size4-Regular.ttf
│ ├── KaTeX_Size4-Regular.woff
│ ├── KaTeX_Size4-Regular.woff2
│ ├── KaTeX_Typewriter-Regular.eot
│ ├── KaTeX_Typewriter-Regular.ttf
│ ├── KaTeX_Typewriter-Regular.woff
│ └── KaTeX_Typewriter-Regular.woff2
├── katex.min.css
├── katex.min.js
├── notebook.css
├── prism.css
└── require.js
├── test
├── extension.test.js
└── index.js
└── vsc-extension-quickstart.md
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "env": {
3 | "browser": false,
4 | "commonjs": true,
5 | "es6": true,
6 | "node": true
7 | },
8 | "parserOptions": {
9 | "ecmaFeatures": {
10 | "jsx": true
11 | },
12 | "sourceType": "module"
13 | },
14 | "rules": {
15 | "no-const-assign": "warn",
16 | "no-this-before-super": "warn",
17 | "no-undef": "warn",
18 | "no-unreachable": "warn",
19 | "no-unused-vars": "warn",
20 | "constructor-super": "warn",
21 | "valid-typeof": "warn"
22 | }
23 | }
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Screenshots**
21 | If applicable, add screenshots to help explain your problem.
22 | Please provide a screen shot with your developer console open. Please follow the below steps.
23 |
24 | 1. Click Help > Toggle Developer Tools
25 | 2. Open a Jupyter notebook
26 |
27 | **Desktop (please complete the following information):**
28 | - OS: [e.g. iOS]
29 | - Version [e.g. 22]
30 |
31 |
32 | **Additional context**
33 | Add any other context about the problem here.
34 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | .vscode-test/
3 | *.vsix
4 | *.mp4
5 | # Logs
6 | logs
7 | *.log
8 | npm-debug.log*
9 | yarn-debug.log*
10 | yarn-error.log*
11 |
12 | # Runtime data
13 | pids
14 | *.pid
15 | *.seed
16 | *.pid.lock
17 |
18 | # Directory for instrumented libs generated by jscoverage/JSCover
19 | lib-cov
20 |
21 | # Coverage directory used by tools like istanbul
22 | coverage
23 |
24 | # nyc test coverage
25 | .nyc_output
26 |
27 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
28 | .grunt
29 |
30 | # Bower dependency directory (https://bower.io/)
31 | bower_components
32 |
33 | # node-waf configuration
34 | .lock-wscript
35 |
36 | # Compiled binary addons (http://nodejs.org/api/addons.html)
37 | build/Release
38 |
39 | # Dependency directories
40 | node_modules/
41 | jspm_packages/
42 |
43 | # Typescript v1 declaration files
44 | typings/
45 |
46 | # Optional npm cache directory
47 | .npm
48 |
49 | # Optional eslint cache
50 | .eslintcache
51 |
52 | # Optional REPL history
53 | .node_repl_history
54 |
55 | # Output of 'npm pack'
56 | *.tgz
57 |
58 | # Yarn Integrity file
59 | .yarn-integrity
60 |
61 | # dotenv environment variables file
62 | .env
63 |
64 |
--------------------------------------------------------------------------------
/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See https://go.microsoft.com/fwlink/?LinkId=733558
3 | // for the documentation about the extensions.json format
4 | "recommendations": [
5 | "dbaeumer.vscode-eslint"
6 | ]
7 | }
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | // A launch configuration that launches the extension inside a new window
2 | {
3 | "version": "0.1.0",
4 | "configurations": [
5 | {
6 | "name": "Extension",
7 | "type": "extensionHost",
8 | "request": "launch",
9 | "runtimeExecutable": "${execPath}",
10 | "args": ["--extensionDevelopmentPath=${workspaceRoot}" ],
11 | "stopOnEntry": false
12 | },
13 | {
14 | "name": "Extension Tests",
15 | "type": "extensionHost",
16 | "request": "launch",
17 | "runtimeExecutable": "${execPath}",
18 | "args": ["--extensionDevelopmentPath=${workspaceRoot}", "--extensionTestsPath=${workspaceRoot}/test" ],
19 | "stopOnEntry": false
20 | }
21 | ]
22 | }
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | }
--------------------------------------------------------------------------------
/.vscodeignore:
--------------------------------------------------------------------------------
1 | .vscode/**
2 | .vscode-test/**
3 | test/**
4 | .gitignore
5 | jsconfig.json
6 | vsc-extension-quickstart.md
7 | .eslintrc.json
8 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 | All notable changes to the "nbpreviewer" extension will be documented in this file.
3 |
4 | Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
5 |
6 | ## [Unreleased]
7 | - Initial release
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Jithu R Jacob
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 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # vscode-nbpreviewer
2 | An extension for supercharging your Data Science workflow by previewing Jupyter Notebook within VS Code. View graphs and interact with Plotly visualizations from within VS Code.
3 |
4 |
5 |
6 |
7 |
8 |
9 | ## Preview
10 |
11 | >
12 |
13 | ## Quick Start
14 | * Install the extension
15 | * Open a Jupyter Notebook
16 | * Click Show Preview menu button from Editor/Title Menu
17 |
18 |
19 | >
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/images/jupyter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jithurjacob/vscode-nbpreviewer/034466c5d13838e02db65d9ab1ede694e61b0036/images/jupyter.png
--------------------------------------------------------------------------------
/images/sample.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jithurjacob/vscode-nbpreviewer/034466c5d13838e02db65d9ab1ede694e61b0036/images/sample.PNG
--------------------------------------------------------------------------------
/jsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "lib": [
6 | "es6"
7 | ]
8 | },
9 | "exclude": [
10 | "node_modules"
11 | ]
12 | }
--------------------------------------------------------------------------------
/language-configuration.json:
--------------------------------------------------------------------------------
1 | {
2 | "comments": {
3 | "lineComment": "//",
4 | "blockComment": [ "/*", "*/" ]
5 | },
6 | "brackets": [
7 | ["{", "}"],
8 | ["[", "]"]
9 | ],
10 | "autoClosingPairs": [
11 | { "open": "{", "close": "}", "notIn": ["string"] },
12 | { "open": "[", "close": "]", "notIn": ["string"] },
13 | { "open": "(", "close": ")", "notIn": ["string"] },
14 | { "open": "'", "close": "'", "notIn": ["string"] },
15 | { "open": "\"", "close": "\"", "notIn": ["string", "comment"] },
16 | { "open": "`", "close": "`", "notIn": ["string", "comment"] }
17 | ]
18 | }
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "nbpreviewer",
3 | "displayName": "VS Code Jupyter Notebook Previewer",
4 | "description": "An easy to use extension for previewing Jupyter Notebooks within VS Code",
5 | "version": "1.2.2",
6 | "publisher": "jithurjacob",
7 | "author": {
8 | "name": "jithurjacob"
9 | },
10 | "keywords": [
11 | "python",
12 | "jupyter",
13 | "ipython",
14 | "data science",
15 | "kaggle",
16 | "notebook",
17 | "markdown"
18 | ],
19 | "icon": "images/jupyter.png",
20 | "recommendations": [
21 | "donjayamanne.python"
22 | ],
23 | "galleryBanner": {
24 | "color": "#e46d2e",
25 | "theme": "dark"
26 | },
27 | "qna": false,
28 | "license": "MIT",
29 | "bugs": {
30 | "url": "https://github.com/jithurjacob/vscode-nbpreviewer/issues",
31 | "email": "jithurjacob@gmail.com"
32 | },
33 | "repository": {
34 | "type": "git",
35 | "url": "https://github.com/jithurjacob/vscode-nbpreviewer.git"
36 | },
37 | "homepage": "https://github.com/jithurjacob/vscode-nbpreviewer/blob/master/README.md",
38 | "engines": {
39 | "vscode": "^1.29.0"
40 | },
41 | "categories": [
42 | "Programming Languages",
43 | "Other"
44 | ],
45 | "main": "./src/extension",
46 | "contributes": {
47 | "languages": [
48 | {
49 | "id": "jupyter",
50 | "aliases": [
51 | "Jupyter",
52 | "jupyter"
53 | ],
54 | "extensions": [
55 | ".ipynb"
56 | ]
57 | }
58 | ],
59 | "commands": [
60 | {
61 | "command": "jupyter.showPreview",
62 | "title": "Show preview",
63 | "category": "Jupyter"
64 | }
65 | ],
66 | "menus": {
67 | "editor/title": [
68 | {
69 | "command": "jupyter.showPreview",
70 | "when": "editorLangId == jupyter",
71 | "group": "navigation"
72 | }
73 | ]
74 | }
75 | },
76 | "activationEvents": [
77 | "onLanguage:jupyter",
78 | "onCommand:jupyter.showPreview"
79 | ],
80 | "scripts": {
81 | "postinstall": "node ./node_modules/vscode/bin/install",
82 | "test": "node ./node_modules/vscode/bin/test"
83 | },
84 | "devDependencies": {
85 | "typescript": "^2.6.1",
86 | "vscode": "^1.1.6",
87 | "eslint": "^4.6.1",
88 | "@types/node": "^7.0.43",
89 | "@types/mocha": "^2.2.42"
90 | },
91 | "dependencies": {
92 | "cheerio": "^1.0.0-rc.2",
93 | "file-url": "^2.0.2",
94 | "jsdom": "^11.5.1",
95 | "node-prismjs": "^0.1.1",
96 | "notebookjs": "^0.2.6",
97 | "prismjs": "^1.9.0"
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/src/extension.js:
--------------------------------------------------------------------------------
1 | // The module 'vscode' contains the VS Code extensibility API
2 | // Import the module and reference it with the alias vscode in your code below
3 | const vscode = require('vscode');
4 | const fs = require("fs");
5 | const nb = require("./notebookjs");
6 | const Prism = require('node-prismjs');
7 | const cheerio = require('cheerio');
8 | const fileUrl = require("file-url");
9 | var path = require("path");
10 |
11 | const notebook_style_path = vscode.Uri.file(path.join(__dirname, '..', "static", 'notebook.css'));
12 | const notebook_style_src = notebook_style_path.with({ scheme: 'vscode-resource' });
13 |
14 | const prism_style_path = vscode.Uri.file(path.join(__dirname, '..', "static", 'prism.css'));
15 | const prism_style_src = prism_style_path.with({ scheme: 'vscode-resource' });
16 |
17 | const katex_style_path = vscode.Uri.file(path.join(__dirname, '..', "static", 'katex.min.css'));
18 | const katex_style_src = katex_style_path.with({ scheme: 'vscode-resource' });
19 |
20 |
21 | const custom_style_path = vscode.Uri.file(path.join(__dirname, '..', "static", 'custom.css'));
22 | const custom_style_src = custom_style_path.with({ scheme: 'vscode-resource' });
23 |
24 | const require_script_path = vscode.Uri.file(path.join(__dirname, '..', "static", 'require.js'));
25 | const require_script_src = require_script_path.with({ scheme: 'vscode-resource' });
26 |
27 | const katex_script_path = vscode.Uri.file(path.join(__dirname, '..', "static", 'katex.min.js'));
28 | const katex_script_src = katex_script_path.with({ scheme: 'vscode-resource' });
29 |
30 |
31 | const katex_auto_script_path = vscode.Uri.file(path.join(__dirname, '..', "static", 'auto-render.min.js'));
32 | const katex_auto_script_src = katex_auto_script_path.with({ scheme: 'vscode-resource' });
33 |
34 | const custom_script_path = vscode.Uri.file(path.join(__dirname, '..', "static", 'custom.js'));
35 | const custom_script_src = custom_script_path.with({ scheme: 'vscode-resource' });
36 |
37 | // this method is called when your extension is activated
38 | // your extension is activated the very first time the command is executed
39 | const statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
40 |
41 | function convertDocToHTML(panel) {
42 | statusBarItem.show();
43 | statusBarItem.text = "1/6 Starting Rendering";
44 | // Get the current text editor
45 | let editor = vscode.window.activeTextEditor;
46 | if (!editor) {
47 | vscode.window.showErrorMessage("Failed to identify editor");
48 | statusBarItem.hide();
49 | return "Failed to identify editor";
50 | }
51 |
52 | let doc = editor.document;
53 |
54 | // Only update status if a Markdown file
55 | if (!(doc.languageId === 'jupyter')) {
56 | vscode.window.errorMessage("Active editor doesn't show a Jupyter notebook - cannot preview.");
57 | statusBarItem.hide();
58 | return "Active editor doesn't show a Jupyter notebook - cannot preview.";
59 | }
60 | var data = "";
61 | try {
62 | statusBarItem.text = "2/6 Extracting Jupyter Notebook";
63 | var text = doc.getText();
64 | var ipynb = JSON.parse(text);
65 | statusBarItem.text = "3/6 Parsing Jupyter Notebook";
66 | var notebook = nb.parse(ipynb);
67 | statusBarItem.text = "4/6 Rendering Jupyter Notebook";
68 | var notebook_html = notebook.render().outerHTML;
69 | statusBarItem.text = "5/6 Highlighting Jupyter Notebook";
70 | //traverse through notebook and use prism to highlight
71 | const $ = cheerio.load(notebook_html);
72 | var elems = $('.nb-input pre code');
73 | for (var i = 0; i < elems.length; i++) {
74 | var formatted_text = Prism.highlight($(elems[i]).text(), Prism.languages.python);
75 | $(elems[i]).html(formatted_text); // modify inner HTML
76 | }
77 | notebook_html = $.html();
78 | data = '';
79 | data += '';
80 | data += '';
81 | data += '';
82 |
83 | // data += '';
84 | data += '';
85 | data += '';
86 |
87 | data += "" + notebook_html + "";
88 | data += '';
89 |
90 |
91 | } catch (error) {
92 | data = "An error occured while converting Notebook to HTML";
93 | vscode.window.showErrorMessage("An error occured while converting Notebook to HTML");
94 | console.error("An error occured while converting Notebook to HTML", error);
95 | }
96 | statusBarItem.hide();
97 | return data;
98 | }
99 |
100 | function generatePreview(panel) {
101 | var html_body = convertDocToHTML(panel);
102 | return `
103 |
104 |
105 |
106 |
107 | Preview
108 | `+ html_body + ``;
109 | }
110 |
111 | function generateProgressMessage(message) {
112 | return `
113 |
114 |
115 |
116 |
117 | Preview
118 | `+ message + ``;
119 | }
120 |
121 | function activate(context) {
122 | // Use the console to output diagnostic information (console.log) and errors (console.error)
123 | // This line of code will only be executed once when your extension is activated
124 | console.log('Congratulations, your extension "nbpreviewer" is now active!');
125 | // The command has been defined in the package.json file
126 | // Now provide the implementation of the command with registerCommand
127 | // The commandId parameter must match the command field in package.json
128 | let disposable = vscode.commands.registerCommand('jupyter.showPreview', async function (obj) {
129 | // The code you place here will be executed every time your command is executed
130 | try {
131 |
132 | // const success = await vscode.commands.executeCommand('vscode.previewHtml', previewUri, vscode.ViewColumn.Two, 'IPython Notebook Preview');
133 | // Create and show panel
134 | const panel = vscode.window.createWebviewPanel('nbpreviewer', "Jupyter Notebook Previewer", vscode.ViewColumn.One, { enableScripts: true,retainContextWhenHidden: true });
135 | panel.webview.html = generateProgressMessage("Starting to render Jupyter Notebook");
136 | // And set its HTML content
137 | panel.webview.html = generatePreview(panel);
138 | console.log("successfully showed notebook");
139 | }
140 | catch (reason) {
141 | console.error(reason);
142 | vscode.window.showErrorMessage("An error occured while rendering the Notebook");
143 | }
144 | });
145 |
146 | context.subscriptions.push(disposable);
147 | }
148 | exports.activate = activate;
149 |
150 | // this method is called when your extension is deactivated
151 | function deactivate() {
152 | }
153 | exports.deactivate = deactivate;
--------------------------------------------------------------------------------
/src/notebookjs/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 |
--------------------------------------------------------------------------------
/src/notebookjs/.npmignore:
--------------------------------------------------------------------------------
1 | node_modules
2 |
--------------------------------------------------------------------------------
/src/notebookjs/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 |
--------------------------------------------------------------------------------
/src/notebookjs/Makefile:
--------------------------------------------------------------------------------
1 | notebook.min.js: notebook.js
2 | uglifyjs < notebook.js > $@
3 |
--------------------------------------------------------------------------------
/src/notebookjs/README.md:
--------------------------------------------------------------------------------
1 | # notebook.js `v0.2.7`
2 |
3 | Notebook.js parses raw [IPython](http://ipython.org/)/[Jupyter](http://jupyter.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(raw_ipynb_json_string);
21 | var rendered = notebook.render();
22 | document.body.appendChild(rendered);
23 | ```
24 |
25 | ### IO.js Usage
26 |
27 | *Note: To take advantage of `jsdom`'s latest features/bugfixes, `notebook.js` now runs on [io.js](https://iojs.org/) instead of Node.js.*
28 |
29 | To install:
30 |
31 | ```sh
32 | npm install notebookjs
33 | ```
34 |
35 | Then parse, render, and write:
36 |
37 | ```js
38 | var fs = require ("fs");
39 | var nb = require("notebookjs");
40 | var ipynb = JSON.parse(fs.readFileSync("path/to/notebook.ipynb"));
41 | var notebook = nb.parse(ipynb);
42 | console.log(notebook.render().outerHTML);
43 | ```
44 |
45 | ## Markdown and ANSI-coloring
46 |
47 | By default, notebook.js supports [marked](https://github.com/chjj/marked) for Markdown rendering, and [ansi_up](https://github.com/drudru/ansi_up) for ANSI-coloring. It does not, however, ship with those libraries, so you must `