I’m looking for a plugin that is compatible up to the current version of WordPress (3.1.1 as of writing of this question) and that supports some kind of inline highlighting of programming language syntax. Basically, I want to be able to write a function name
or a variable name
or a quick if statement
as part of a paragraph and have it look like code
, much like what you get in the StackExchange editor with the backticks
.
There are several good plugins for highlighting programming language syntax in WordPress, but they don’t seem to support inline syntax highlighting.
jQuery.Syntax claims to have the inline capability, but I can’t get it to work on WordPress 3.1.1.
If you still want to use SO-type backtick markup for styling your inline code examples, I’ve created some code that will accomplish it. To make it into your own plug-in, just add the code below to your functions.php. It calls the wordpress filter “the_content” to apply the transformation to the content when it is displayed, thereby keeping any transformations from becoming stored in the database.
Now, I tested the code above with some dummy text and used backticks to define code blocks like so:
Then applied the following css:
And what I get looks like this:
Hope this works for you.