Sweating the Details

Icon

A Compulsively Obsessing Blog

WP-Syntax Colorizer

WP-Syntax is a fantastic WordPress plugin which automatically syntax-highlights source code in <pre> blocks for a large number of languages, using GeSHi. Unfortunately, styling WP-Syntax’s output can be a bit of a headache, particularly with regard to some undocumented functions.

I have put together WP-Syntax Colorizer, a WordPress plugin that gathers all of the work required to set custom colors for your code snippets, and you can simply run it alongside WP-Syntax. Customizing couldn’t be easier.

Example

The following code snippet has been styled with WP-Syntax Colorizer:

$query = "SELECT u_username, u_firstName, u_lastName FROM userTable";
$users = mysql_query($query);
while($row = mysql_fetch_assoc($users))
{
	echo "
"; echo "".$row['u_username']." ". $row['u_username']." ".""; echo "
"; }

Installation

  1. Upload wp-syntax_colorizer.php to the /wp-content/plugins/ directory.
  2. Edit the colors in wp-syntax_colorizer.php to fit your needs.
  3. Upload the modified wp-syntax.css into the root directory of your theme, if you want to match a dark-colored theme.
  4. Activate the plugin through the ‘Plugins’ menu in WordPress.

Where to get it

You can find a download link for the plugin here at WordPress.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Reddit
  • Technorati
  • Tumblr
  • Twitter

Category: Web Development

Tagged: , , ,

5 Responses

  1. sharms says:

    At the end of wp-syntax_colorizer.php, I added:

    $geshi->set_methods_style(1, 'color: #19ccff', true);

    Which makes it so you can color the methods also.

  2. Thanks sharms! I’ll add this in the next release.

  3. greg says:

    nice feature. It would be nice if there were some default colors for html and php for the truely lazy among us.

  4. Thanks sharms, Very Great Tips…

  5. rainer says:

    currently im using wordpress 3.0.1 and dont know why i cant call this plugin into post. can you help me in this? its quite frustating since the instalation works fine

Leave a Reply

About

Arash Keshmirian is a co-founder of Limbic Software, developers of TowerMadness for the iPhone. In this blog, he writes about issues facing software developers, entrepreneurs, and his generation as a whole...
...or he'll just post some random art.

Twitter: @akgfx

Email:

Flickr Photos

_MG_4389

_MG_4388

_MG_4387

More Photos