Escape diff tokens — the diff library has issues with & and $.
String escapeDiffTokens(String text) { return text.replaceAll('&', '\u0000&').replaceAll('\$', '\u0000\$'); }