nbdiff icon indicating copy to clipboard operation
nbdiff copied to clipboard

Implement Markdown diffs

Open selenaaa opened this issue 12 years ago • 9 comments

selenaaa avatar Feb 10 '14 00:02 selenaaa

I'm trying to implement diffing/merging of markdown cells right now. The diffing is trivial, however I cannot figure out which templates or code to modify to teach the server to represent the diffed cells (right now they are just omitted). Can you please provide some pointers to the code responsible for rendering the diff or merge?

akhmerov avatar Dec 21 '14 10:12 akhmerov

Hello, The short answer is, it's in nbdiff/server/static/js/nbdiff.js It's rendered in javascript with the help of IPython rendering code. I'll have to refresh my memory to see how it was done if you want more pointers. I'm not sure I remember what this enhancement is about, because when I diff/merge I actually see Markdown properly formatted.

bpipev avatar Dec 22 '14 22:12 bpipev

It's properly formatted, but it isn't diffed with the current master, so the cells are basically considered indivisible.

I'll see if I can modify the server, but more pointers would of course be appreciated.

akhmerov avatar Dec 22 '14 22:12 akhmerov

Yes, you are correct. I'll take a look at it.

bpipev avatar Dec 22 '14 22:12 bpipev

The diff code is boilderplate, see akhmerov/nbdiff@4984ba97337c1868c0d895fd7b78c556ce317bc3

Looking through the server code would take me more time, but it's probably as simple.

akhmerov avatar Dec 23 '14 10:12 akhmerov

It looks right. For the front end, you can add a new condition here https://github.com/tarmstrong/nbdiff/blob/master/nbdiff/server/static/js/nbdiff.js#L295 and create a new class to handle it like HeaderDiff, or reuse it if it works for you.

bpipev avatar Dec 23 '14 17:12 bpipev

See #235, it was easy indeed. Any pointers for nbmerge?

akhmerov avatar Dec 23 '14 19:12 akhmerov

I'm not sure if I can help much. ~~It probably has to be done from scratch.~~ I'll take a look at what can be done.

bpipev avatar Dec 23 '14 22:12 bpipev

OK, nbmerge anyway only works on cell level even for code cells. So then there's nothing easy I can do, and the pull request is complete.

akhmerov avatar Dec 23 '14 22:12 akhmerov