Sometimes, when I'm reviewing a really long, complex, or high-stakes pull request diff, I'll be inclined to print it out and mark it up on paper. That is… not very cost-effective, and I don't own a printer these days. But the context switch away from my computer, and being able to physically mark up the code, really does help!
So, what am I to do? Well, I do have a reMarkable e-paper tablet (#notsponsored) that'll take PDFs and let me write on them with a stylus, which turns out to be just as good for this use case.
But, it's a grayscale display, so the usual color diff formatting won't help. And obviously git diff outputs ANSI escape codes, not a PDF. So how do we get to what we need here?
Of course, we start by getting a diff:
~/my-project $ git diff --color=always "HEAD~" HEAD > patch
Next we'll use aha to convert it to an HTML file. This way, we can easily control the styles so they render nicely on e-ink. I usually install this with nix-shell -p aha.
Before converting, let's define our styles. Put these in a file called style.css. This particular set has green/added text show up on a distinct background, and red/removed text displayed with a strikethrough; this is what I consider the minimum viable e-ink stylesheet. You can make text bigger or do whatever you want here too.
.red { text-decoration: line-through !important; }
.green { background-color: #ddd; }
span { text-wrap: wrap; }
Make the HTML diff:
~/my-project $ aha --stylesheet --css style.css < patch > patch.html
Now you have patch.html, which you can print to PDF and upload to your e-ink device for markup or review!