I usually use Javascript for that, like prettify, or SyntaxHighlighter.
As an example you're welcome to take a look at Pastelyst, which is a Catalyst driven pastebin Here.
Comment on Re: How do I display code using a pretty print type to the browser?