In [1]:
!date
Sat May 25 08:46:20 PDT 2013

A notebook to diff notebooks

Step 1, use nbconvert to turn ipynb files into html.

In [2]:
cd ../nbconvert/
/snfs2/HOME/abie/nbconvert
In [3]:
!./nbconvert.py --format html nbdt1.ipynb
======================================================
Warning, we are deprecating this version of nbconvert,
please consider using the new version.
======================================================
    
In [4]:
!./nbconvert.py --format html nbdt2.ipynb
======================================================
Warning, we are deprecating this version of nbconvert,
please consider using the new version.
======================================================
    

Step 2, use html diff.py to generate html diff

In [5]:
!wget http://www.aaronsw.com/2002/diff/diff.py
--2013-05-25 08:51:37--  http://www.aaronsw.com/2002/diff/diff.py
Resolving www.aaronsw.com... 75.127.96.63
Connecting to www.aaronsw.com|75.127.96.63|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1916 (1.9K) [text/x-python]
Saving to: “diff.py.1”

100%[======================================>] 1,916       --.-K/s   in 0s      

2013-05-25 08:51:37 (224 MB/s) - “diff.py.1” saved [1916/1916]

In [8]:
!python diff.py nbdt1.html nbdt2.html >nbdt_diff.html
In [10]:
from IPython.core.display import HTML
In [11]:
HTML(filename='nbdt_diff.html')
Out[11]:
In [1]:
!date
Fri May 24 23:19:03 PDT 2013

This is a test of an nbconvert+html_diff approach to seeing what has changed in ipynb files.

In [2]:
1+1
Out[2]:
2
In [3]:In [6]:
sqrt(1718)
Out[3]:Out[6]:
4.12310562561766064.2426406871192848
In [4]:In [7]:
plot(rand(10))
Out[4]:Out[7]:
[<matplotlib.lines.Line2D at 0x2850350>]0x2a66150>]
In [ ]:In [5]:
!cd /homes/abie/nbconvert/; cp /homes/abie/notebook/*nb_diff_test.ipynb nbdt1.ipynb; ./nbconvert.py --format html nbdt1.ipynb
======================================================
Warning, we are deprecating this version of nbconvert,
please consider using the new version.
======================================================
    

This could use a ton of work on the css, obviously, but it gets the job done for now.

E.g. adding the following makes the prompts not overlap the input cells as badly:

<style type="text/css">
div.prompt {width: 22ex;}
</style>