In my previous post, I posted the perl script with syntax highlighting. I was able to get that code with syntax highlighting directly off the forum post. If you want to post random code with syntax highlighting, there are 3 options –
- Using plugins (generally not available for free)
- Using online generator such as those described here. (Usually give css code which cant be used in free mode of WordPress)
- Htmlize in Emacs 🙂
Emacs has an addon called “htmlize” which can be used to convert any file into an htmlized version. It provides 3 output types – css, inline-css and font. Emacs FTW again :D.
PS :: This is also available in the emacs-goodies.el packages in Debian and Ubuntu but the version of htmlize.el in those is outdated and does not work with Emacs 23.x
EDIT :: It seems that WordPress internally supports syntax highlighting with the use of SyntaxHighlighter. For more info check here. List of all the supported languages is here. For blogs other than WordPress, htmlize still seems a very good option.