26 August 2007

Color Coding ColdFusion Code

I've been working on a website, one of the things I needed was a code formatter.


It's a work in progress, and I won't post the code yet, but it seems to be working. It's based around the code from BlogCFC which looks to be originally written by Dain Anderson.


It had a few bits that I didn't understand, and some formatting that I didn't want. So I have severly hacked it for my own purposes. Here's what I did:
  1. Change it from being script to tag based (refuse to use script until 100% support)
  2. Made use my favourite var local = {} to ensure all variables are scope.
  3. Added a colorCode from file method
  4. Added line numbering to the output
  5. Change the formatting and some of the colors to match DreamWeaver (might add an eclipse option also)
  6. And just a general tidy up of variables that were not being used etc.

Because of the way that it works, lots of regular expressions on <> combo's it won't color it's self properly, not sure I need to fix that.

If your interested in a simple example. NOTE: Link removed, this has been released, see the New Blog Entry.

As usual all comments and suggestions welcome and I will share the code once I finalise it.

3 comments:

pillow said...

I'd love a version once it's finished - now I have to code all my CF examples by hand using HTML and CSS ;-) Automation is the way to go!

spiraldev said...

Would it be possible to get that color code from you I would really like to use it.

Dale Fraser said...

This has now been released

New Blog Entry