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 "<div class="user">";
	echo "<strong>".$row['u_username']."</strong> <em>".
	$row['u_username']." "."</em>";
	echo "</div>";
}

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: , , ,

4 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…

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

Weird Tropical Fruit

Spot the Monkeys!

On the road to Arenal Volcano

More Photos