I have started thinking about displaying little code snippets on my website. And I quickly found out that the out of the box appearance of code samples in WordPress leaves a lot to be desired. So I started hitting the web for plugins and I think I found a winner.
It’s called Google Syntax Highlighter for WordPress and it builds upon this project at Google.
Here is the result:
class CreateEvents < ActiveRecord::Migration
def self.up
create_table :events do |t|
t.string :name
t.datetime :start_time
t.datetime :end_time
t.string :description
t.timestamps
end
end
def self.down
drop_table :events
end
end
I think it looks really good! I was unable to get the copy to clipboard functionality to work with Safari on my Mac. I am planning on investigating that further. I also wish the plugin was able to automatically detect the language of the code snippet rather than specifying it every time via an attribute, as I can see myself constantly hunting down the keywords for each language.
On a brighter note, I did run across this article on adding custom language highlighting. Very cool!
Update: I have switched over to Easy Google Syntax Highlighter as it supports more languages.