WordPress: Customizing WP-Syntax

I noticed a little bug in the WP-Syntax plugin for WordPress – the line numbers don’t match when using code with comments, well at least in Firefox 3.5. I realized it was caused by the italics where the line-height increased by approximately 1 pixel. It’s not that bad when you have a couple of comments in the code, but 60 lines of code with around 10 lines of comments completely broke my line numbers. I figured out WP-Syntax is configurable and here’s how I removed the italics from code comments:

add_action('wp_syntax_init_geshi', 'my_custom_geshi_styles');
function my_custom_geshi_styles(&$geshi) {
    $geshi->set_comments_style(1, 'font-style:normal;', true);
}
// Note that comments are okay now ;)

Place this in your functions.php file and refresh your page. More info about the other $genshi methods could be found in the Genshi Documentation.

About the author

Konstantin Kovshenin

WordPress Core Contributor, ex-Automattician, public speaker and consultant, enjoying life in Moscow. I blog about tech, WordPress and DevOps.

1 comment