Took me a while to figure out that blogger.com does not come with syntax highlighting - duh!
Obviously, there's a way to beautify your code:
trait Friendly { def greet() = ":)" }
trait Dog extends Friendly { override def greet() = "Woof" }
trait Cat extends Friendly { override def greet() = "Meow" }
def f[G <: { def greet() : String }](g:G) = println(g.greet())
f(new Dog with Cat)
The twist is to enhance your blog template by a client-side javascript library:
- Reference Google's prettify library:
<link href="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js"></script>
- Initialize it:
...
<body onload='prettyPrint()'>
...
- Escape your code with a regular <pre> tag:
<pre class="prettyprint">
... # Put your code here
</pre>
One last thing, if escaping html code (< >) drives you crazy, this might come handy:
$ echo '<html>' | sed s/\</\\\<\;/g | sed s/\>/\\\>\;/g
Hey there seems to be some html scrambeling when you view the page in a smaller browser window :)
ReplyDeleteCongrats for starting the blog,
Thorsten