Sunday, May 6, 2012

Adding a Haskell Brush for SyntaxHighlighter in Blogger

Lately I've written several posts about my first steps in Haskell.
The Haskell syntax in my code samples was not being highlighted because SyntaxHighlighter does not have a brush for Haskell (see syntaxes supported here):
mulTable n = [[c * b | b <- xs] | c <- [0..n]] !! n
    where 
        xs = [0..10]
Googling a bit I found out that watashi had developed a custom brush for Haskell.
To use it in blogger, I edited the HTML of my blog by adding this line right below the place where the rest of the brush scripts were being loaded:
<script src='http://blog.watashi.ws/wp-content/uploads/2009/12/shBrushHaskell.js' 
type='text/javascript'/>
Then to highlight the syntax of a Haskell code sample, I just did:
<pre class="haskell" name="code">
mulTable n = [[c * b | b &lt;- xs] | c &lt;- [0..n]] !! n
    where 
        xs = [0..10]
</pre>
And this was the result:
mulTable n = [[c * b | b <- xs] | c <- [0..n]] !! n
    where 
        xs = [0..10]

No comments:

Post a Comment