Sytax highlighting A-go-go

Theres only one thing that I love more than technology and thats code!

I've added the IG: Syntax Higliter plugin to this blog so I can start publishing snippets of code on this blog. The plugin can support php, html, sql, and a whole host of others languages click here to find out more about it.

Below is a fascinating piece of PHP I cranked out to check its working.

PHP:
  1. // completely useless example of some PHP code
  2. $arr = array('Pete', 'is', 'the', 'best!');
  3.  
  4. $html = '';
  5.  
  6. /*
  7. everybody loves a good foreach loop
  8. */
  9. foreach($arr as $key => $value)
  10. {
  11. $html .= $value.' ';
  12. }
  13.  
  14. $html = rtrim($html);
  15. echo $html;
  16. # wow this is great
  17.  
  18. ?>

My only complaint I have about the plugin is it doesn't seem to provide any indentation when it displays the code, even if you paste the code into wordpress nicely indented. Maybe there's a setting to activate this. If anyone can tell me where it is I'll buy them a beer, if you don't drink beer then you can watch me drink two instead.

// Pete Graham

Comments 4

  1. Pete wrote:

    Just noticed that the PHP keywords are hyperlinks to their definitions on the PHP website, that’s pretty damn sweet!

    Posted 26 Jan 2007 at 1:03 pm
  2. Phevans wrote:

    That’s some sweet looking highlighting. However the HTML is produces is a fricking nightmare. The reason your indentation is being lost is that it’s chucking each line of code into an li in an ol. The tabs are all gone for good :(

    Posted 26 Jan 2007 at 1:11 pm
  3. sim wrote:

    That is phat.

    Posted 26 Jan 2007 at 1:14 pm
  4. Pete wrote:

    Yeh the HTML is a bit nasty, although it will do until I find a better replacement.

    Its my new policy to put things in place that actually achieve a task, rather than spend ages attempting to find/create a prefect solution and not actually completing anything.

    Posted 26 Jan 2007 at 1:16 pm

Trackbacks & Pingbacks 2

  1. From Optimus Pete » Blog Archive » Curse you Internet Explorer! on 27 Jan 2007 at 4:41 pm

    [...] I was pretty pleased with the code syntax highlighting plugin I installed yesterday, just before I was about to finish work I got the Blog up in IE6 Arrrggghhh! IE6 redenders the width of the main content column smaller than Firefox and IE7, this causes the main content to be displayed below the content in the right sidebar, not good. [...]

  2. From Optimus Pete » Blog Archive » IG Syntax Higliter CSS Width Fix for IE6 on 28 Jan 2007 at 6:44 pm

    [...] If you have a site with a narrow main content area like this blog then the IG Syntax Highliter plugin can break your layout in Internet Explorer 6. This problem can be easily solved by modfying the file syntax_hilite_css.css. Here is where this file is located: [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *