Syntax Highlighting code

I’m using the Code Prettify by Dean Lee.

To syntax highlight a code you have to put the code between the

<pre class="prettyprint">...</pre>

tags.

For example, a java code can be pretty-printed like this:

package test;

public class Test {
public static void main(String[] args){
System.out.println("Hello, World!");
}
}

In order to make it work, I have to put the following code to the header template of the theme i’m using.

<script type="text/javascript">
window.onload = function(){prettyPrint();};
</script>

Here is another example of a bash shell script. I modified the .css file in order to make the code bold-face.

#!/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
Advertisements

Published by

Bobby Corpus

Is an IT Architect.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s