If you have Ruby in your stack, it's easy -- use github's own https://github.com/github/linguist
You might also be able to use just the language definition files from https://github.com/syntaxhighlighter