I’ve moved my blog to a new host that lets me use the full features of WordPress. The first implementation of this is the Code Prettify plugin. Once you’ve installed the plugin to your WordPress site, it adds some quick and easy syntax highlighting to tagged code.
In-line code looks like this: print "Hello, world!".
Just use the <code>Your Code Here</code> tags.
Code blocks look like this:
for item in items: print item
For these, use the <pre> tags like this:
<pre>
Your Code Here: With White Space Respected
</pre>
Both of these tags will give you some nice monospaced font and some subtle syntax highlighting. I wanted my code to stand out a little bit more, so I used WordPress’s customization options to add a background property. After selecting the Customize menu on WP, I went to the last option, Additional CSS.
Then I added some simple CSS style, which shows off what I want:
code, pre { background: #EEEEEE; }
It’s that easy! This added the light gray background that you can see above and here:
print("Thanks for reading!")