Google Code Prettify for wordpress

This small wordpress plugin enable syntax highlighting of code snippets in your post using Google Code Prettify.

Notice: you will need to have JavaScript enabled in your browser for this to work.

I had developed another Source Code syntax highlighting plugin using Geshi before,but they are totally different things.with Geshi,code is parsed on the server side,no javascript is needed.

It’s hard to say which is the better,choose one based on your own needs.

Download Google Code Prettify for wordpress v1.1

Installation

This plugin requires WordPress v.2.0 or later.

  1. unzip and upload the files to your wp-content/plugins/ directory.
  2. Activate the plugin by logging into your WordPress administration panel, going to ‘Plugins’, then clicking the  ‘Activate’  button for  ‘Google Code Prettify’.
  3. Done,enjoy it.

Usage

Put code snippets in <pre class="prettyprint">…</pre> or <code class="prettyprint">…</code> and it will automatically be pretty printed.

Example

Bash

#!/bin/bash

# Fibonacci numbers
# Writes an infinite series to stdout, one entry per line
function fib() {
  local a=1
  local b=1
  while true ; do
    echo $a
    local tmp=$a
    a=$(( $a + $b ))
    b=$tmp
  done
}

# output the 10th element of the series and halt
fib | head -10 | tail -1

More examples

FAQ (from http://code.google.com/p/google-code-prettify/)

  1. Which languages does it work for?
    The comments in prettify.js are authoritative but the lexer should work on a number of languages including C and friends, Java, Python, Bash, SQL, HTML, XML, CSS, Javascript, and Makefiles. It works passably on Ruby, PHP and Awk and a decent subset of Perl, but, because of commenting conventions, doesn’t work on Smalltalk, Lisp-like, or CAML-like languages.
  2. How do I specify which language my code is in?
    There’s no way to tell it which language because would complicate the interface. If it doesn’t guess the language properly, that’s a bug.
  3. Which browsers does it work with?
    It’s been tested with IE 6, Firefox 1.5 & 2, and Safari 2.0.4. Look at the test page to see if it works in your browser.
Related posts:

TAGS: , , , , , ,


104 Comments »

« Previous1110987654...21Next »
LIC India On February 17th, 2010 at 10:17 pm (#)

Amazing! Thanks for such a Good thing. Keep up Good work. :-)

LIC India On February 4th, 2010 at 3:19 am (#)

Amzing Post!

Adam K. On February 2nd, 2010 at 11:53 pm (#)

Nice one ! Balle balle!

DKiaulakis On February 1st, 2010 at 6:24 am (#)

File Manager doesn't work. I've upgraded CKeditor to 3.1
Maybe will be changed file manager to any else?
When will be update for this plugin?
Thank you for really useful tool.

Kaplang On August 10th, 2009 at 5:22 am (#)

thanks for the pluggin :)

SNOW BRIDGE 使用中プラグイン - On July 31st, 2009 at 1:10 am (#)

[...] コードに色づけしてくれる。他にも、Google Code Prettify for wordpress とか SyntaxHighlighter [...]

adnan On July 8th, 2009 at 10:37 pm (#)

Google Code Prettify For WordPress is great plugin..and useful..
need some screen shorts for help…

MonstroMoi » Blog Archive » Google Code Prettify On July 8th, 2009 at 6:53 am (#)

[...] Version 1.1 | Par Dean Lee | Aller sur le site de l’extension [...]

17 of 26 » Blog Archive » The Search for a WordPress Plugin to Display Code On July 2nd, 2009 at 9:16 am (#)

[...] highlighting there. Turns out that they use Google’s Prettify and there’s a WordPress plugin implemented with it. That plugin also did not work well under WordPress 2.8 (the posted version is [...]

Best Wordpress Plugin for Code Highlighting for ActionScript3 On June 30th, 2009 at 12:07 pm (#)

[...] Dean Lee’s, Javascript based one from google [...]

« Previous1110987654...21Next »

Leave a comment


(will not be published)