Sunday, August 10, 2008

New Highlighter Version

I cleaned up the code and changed the way nested languages works. The IE bug turned out to be an error in IE's handling of innerHTML for <pre> and certain other elements. It was easily worked around by wrapping an extra <pre> around it. I also made the line numbers non-selectable in FF and IE. I haven't shown off line-numbers really, but here's an example:

I generated it at my own computer, obviously using a different style sheet than I use on this blog.

The currently supported languages are: html, xml, css, ebnf, php, javascript, java, haxe, and a few others. I plan to add ruby, perl, C# and C++ (and C) some time this weekend.

EDIT: Alright, I added those languages. Click here to see the examples.

10 comments:

Anonymous said...

hi,
i've coded a paste-board in haxe (php) using your highlighter class. works like a charm, thanx a lot!
http://paste.disktree.net/

Ahnfelt said...

Thanks for using it. I found a highlighting bug in
http://paste.disktree.net/2 where it would fail to recognize escaped single quotes in a character literal. It's been fixed on svn:
http://svn.ahnfelt.dk/highlighter

Anonymous said...

thanks for the source!!
a suggestion:
how about renaming the class to "CodeHighlighter". would explain the functionality more exactly. ( Highlighter for what ? )
yours.tong

Ahnfelt said...

Good idea. Done :-)

alicetaylor said...

I am happy to find this post very useful for me

http://word-cookies-answers.com

Unknown said...

I'm puzzled with lots of exercises. I was afraid I could not do the right time despite my hard work. I need a support person.
run3play.com

sendul said...

By reading this article I get a lot of lessons and this is very useful . cara menggugurkan kandungan

Unknown said...

I know there will be many difficulties and challenges but I am determined to do it. If it does not succeed then it will be a lesson for me as well
catmario4.com

Linda said...


I understand what you bring it very meaningful and useful, thanks.
run3unblockedgame.com

Tangki Fiber said...

You managed to hit the nail upon the top and also defined out the whole thing without having side effect , people could take a signal. Will likely be back to get more. Thanks
Tangki Panel