1

I'm making a blog in PHP and I'd really like to have syntax highlighting on Haskell code.

Are there any tools for that out there?

I've found hscolour but I don't know if it's possible to integrate it in PHP.

I'm using CakePHP if that makes a difference.

Thanks.

7 Answers 7

3

GeSHi is a PHP library that's quite often used for code-highlighting.

Judging from the list of supported languages, it seems it supports Haskell -- and there's a demo page if you want to try first.

(Right now, the website seems not to be responding :-( Still, it's available from Google search's cache)

Sign up to request clarification or add additional context in comments.

Comments

3

I use SHJS JavaScript syntax highlighter. It is based on on GNU Source-highlight, and highlights more correctly than google-code-prettify and GeSHi.

See also: How to setup SHJS for Haskell.

Comparison, the last time I checked:

  • SHJS test:
    1. OK, live example
  • highlight.js test
    1. doesn't distinguish --> operator from the comments
    2. doesn't support nested comments
    3. problems with an apostrophe
  • google-code-prettify test:
    1. doesn't distinguish --> operator from the comments
    2. doesn't support nested comments
  • GeSHi test:
    1. doesn't distinguish --| operator from the comments
    2. doesn't support nested comments
    3. doesn't handle string escapes

Comments

1

The web site is down at the moment, so I can't confirm, but I am most positive GeSHi has support.

Comments

0

Many tools support Haskell syntax highlighting: kate, GeSHI, pygments. Calling into haskell-color or hscolour. Pick whichever is easiest for you to interface with.

Comments

0

Here is a Geshi helper for CakePHP: http://www.mech7.net/articles/view/7/cakephp-geshi-helper

Comments

0

I really like how GitHub highlights Haskell code, so I hacked at GeSHi's Haskell syntax file for a while until it worked in a similar fashion. It hasn't been heavily tested, but someone might find it useful.

You can download it from my blog entry, GitHub Haskell colours for GeSHi.

Comments

0

You could use the Alex Gorbatchev's SyntaxHighlighter. Its javascript and really simple and well supported, easy to install and modify. Here are some instructions for blogger... but all you have to do you to do is remove the blogger=true line for a php CakeApp.

http://code-slim-jim.blogspot.com/2010/11/adding-syntax-higher-to-your-blog.html

And here is the Haskel brush for it:

https://github.com/mrueegg/haskell_syntax_highlighter

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.