We used to escape a diff only after it was formatted. This would cause some elements to hang the interface (like an iFrame)
This steals the idea and markup from Gitnub. Thanks! :)