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>


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();};

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


# 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 ))

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

Published by

Bobby Corpus

Loves to Compute!

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s