Tuesday, August 24, 2010

Haskell Syntax Highlighting for Blogs

Can anyone recommend a good way to get Haskell syntax highlighting for blog posts? I've been using Gist, which works very well, except that Gists don't show up in RSS feeds.


  1. See this [1] or this [2]

    [1]: http://greayer.wordpress.com/2009/10/26/blogging-literately-in-haskell/
    [2]: http://pgraycode.wordpress.com/2010/07/28/enter-hacoteb/

  2. Use pandoc and make sure to "cabal install" it with the "-f highlighting" option -- you can then highlight code using the syntax:

    ~~~~~~~~~~ {.haskell}
    foo :: Int -> Int
    foo = (+2)

    This is the most convenient way I've found.

  3. We [1] use code colorer [2], a WordPress plugin apparently based on GeSHi [3]. It's basic, but works well and supports other languages as well.

    [1] https://blog.typlab.com/
    [2] http://wordpress.org/extend/plugins/codecolorer/
    [3] http://qbnz.com/highlighter/

  4. For my blog, I ran the code through hscolour and generate html output and then I added the CSS classes to my blog template.

  5. You can also use "Highlight" executable that is optional with highlighting-kate:

    cabal install highlighting-kate -fexecutable

  6. Google's code-prettify looks to support Haskell but I haven't used it myself (yet): http://code.google.com/p/google-code-prettify/

  7. Followup: Actually, these instructions for getting Blogger to use Google's code prettify work on my blog: http://lukabloga.blogspot.com/2008/10/to-test-new-highlighting.html

    Best of luck!

  8. Sigh... Sorry for triple posting, but I don't see an edit button: You'll need to add one more script include to this file: http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-hs.js

    and also follow the instructions there for posting.

  9. I write my blog posts (http://randomagent.wordpress.com) in emacs with org-mode. When editing code, org-mode gives control to the major mode associated with that language.

    Then, when you export your text to html to past on your favourite blog manager, org-mode uses the adequate major mode to highlight your code and export the right html code for the colors.

  10. I use SHJS to highlight Haskell syntax with JavaScript. It highlights more correctly than google-code-prettify.


  11. Following Eric@Typlab's suggestion (thanks!), I'm using CodeColorer with Wordpress 3.3 and it works beautifully.

    -- Ivan @ Keera Studios

    PS. I know that this is an old thread, but it's still the first result when you google "haskell wordpress code highlighting".