A Code Highlighter in WordPress

I wrote a post on how to let Python work with C last week. However, at the finalising stage, I wrangled with the format of the post so that the codes are easy to read with as much the effort as I wrote the article, and without much luck. Hence I postponed the post. Until today, I stumbled across some other guys tutorial, where the codes look very pretty. An inspection with Safari shows that the code is rendered by a WordPress plugin called Cryon Syntax Highlighter. As this can become handy if it is to use WordPress to manage miscellaneous technological knowledge, so the code prettifier deserves a standalone post.

As long as you can install it, which is only a few clicks away, there is not too much to say about its usage. Let’s see an example in Python:

May be a helpful suggestion is that as within a browser, your <tab> will be explained as to jump over the page-elements, it might be a good idea to edit the code outside the blog post in, say, vim. Then paste into the Crayon’s code formatter.

Another trick is the inline tags. I am lazy and want to stay with the good old <code> tag. But this requires enabling the option of “capture <code> as inlineTag” in the settings of Crayon PlugIn. A final note, if your code contains example of the code-tag itself, it is wise to delegate the job to Crayon, just inspect the source code of this page to see why.