user50685
user50685

Reputation:

How to get Haskell syntax highlighting on PHP blog

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.

Upvotes: 1

Views: 769

Answers (7)

sastanin
sastanin

Reputation: 41481

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

Upvotes: 3

Ashley Smart
Ashley Smart

Reputation: 2134

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

Upvotes: 0

Jacob Stanley
Jacob Stanley

Reputation: 4814

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.

Upvotes: 0

Vladislav Rastrusny
Vladislav Rastrusny

Reputation: 29965

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

Upvotes: 0

Don Stewart
Don Stewart

Reputation: 137947

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

Upvotes: 0

LiraNuna
LiraNuna

Reputation: 67232

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

Upvotes: 1

Pascal MARTIN
Pascal MARTIN

Reputation: 400932

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)

Upvotes: 3

Related Questions