I know this is just some draft UI, but the `$sanitize` service does this encoding. It's probably more robust to pipe this through `$sanitize` and then [prettify](https://code.google.com/p/google-code-prettify/), but I won't wait for that change to land this on develop.

Just FYI, if you want to do some more cleanup/refactoring after.