Skip to content

Instantly share code, notes, and snippets.

@ethanwhite
Forked from jiffyclub/nbviewer_bookmarklet.js
Created October 17, 2012 01:33
Show Gist options
  • Save ethanwhite/3903236 to your computer and use it in GitHub Desktop.
Save ethanwhite/3903236 to your computer and use it in GitHub Desktop.
A bookmarklet that tries to open the current page in nbviewer. White space has been trimmed for brevity. To use make a new bookmark and copy the code below into the URL field.
javascript:date=new Date();
url_root='http://nbviewer.ipython.org/';
url=null;
gist=location.href.match(/^https?:\/\/gist.github.com\/([0-9]+)$/);
if (gist) {
url = url_root + gist[1];
} else {
path=location.href.match(/^https?:\/\/(.*\.ipynb)$/);
if (path) {
url=url_root + 'url/' + path[1];}}
if (url) {
void(window.open(url, 'nbviewer' + date.getTime()));}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment