Tuesday, November 22, 2005

Highlight my Code

I think you have seen many web sites highlighting their codes like this


include 'me.php';

//my name

$name = 'ahmed';

print $name;


that's not a big problem when we can use some builte-in php functions like highlight_string .
this function highlights php codes only, but what can i do to highlight codes from other languages like C#, C++, Java ...etc.
i have found some tools can help you to work this out like GeSHi and pear::Text_Highlighter
this two classes have the ability to highlight what ever you want of codes in simple steps.

GeSHi have a big number of already supported languages so i don't have to create it by myself again. Also i can add my custom language support like its sister in pear.
IMO GeSHi is faster and better as your languages information stored in php files but with Text_Highlighter you will add this information in XML files.
think about the used memory resources to read this file (big file) and the time of execution.
may i'm wrong but i will leave you to test it your self.


Post a Comment

<< Home