This is essentially Dr Drang’s script for syntax highlighting and adding line numbers to code snippets, which calls [highlight.js][hljs] to do the colouring.
My code is largely the same, but rewritten to not require JQuery and done so in the module pattern to keep functions out of the global namespace. (On [my site][rjw] this is my personal JavaScript file, so I’d also stick any other functions I write myself inside the module.)