I have spent the last two days trying to find a code highlighter that actually works with CKEditor and WordPress. I've found Crayon Syntax, and it almost works the way I want. And frankly, that's close enough.
To make it work,
- Install it (duh)
- Configure it to use its "fallback" (ie default) language as PgSQL
- Whenever you want to highlight some code, select it and mark it as "Formatted"
Behold how your SQL code is marvellously highlighted, eg:
USE [master] GO CREATE LOGIN [eviladmin] WITH PASSWORD=N'test', DEFAULT_DATABASE=[master], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF GO EXEC master..sp_addsrvrolemember @loginame = N'eviladmin', @rolename = N'sysadmin' GO
I say it "almost" works because it does break when the SQL code includes characters that aren't strictly SQL. For example, this command:
"exec xp_cmdshell "echo USE [master] > c:\sqlcommands.txt""
gets mangled because of the greater than sign, into:
exec xp_cmdshell "echo USE [master] > c:\sqlcommands.txt"
But I've decided I can live with that.