color diff to pdf

Sometimes you want to explain changes you did to a text in (La)TeX, or perhaps to source code, as a coloured diff produced by your favourite VCS, such as git in my case, by attaching it to an email. The net is full of various scripts to do so, with various degree of success; however, all you need is an installation of enscript, something that is standard on most Linux systems, or at least used to be so.

enscript understands a lot of different programming languages, and can highlight them, and not only them, but also various diff files, e.g., something that git normally produces, unified diffs. Now if your diff is saved in a file blah.diff, you can do

enscript -o blah.ps --color -Ediffu blah.diff

to create Postscript file blah.ps with nicely coloured diff. (And you can also produce HTML instead, or convert Postscript to PDF.)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: