Page 1 of 2

code highlighting

Posted: Tue Aug 25, 2009 3:56 am
by ghosttie
As this is a Jade forum, it would be really cool if the Code tag did Jade code highlighting, for example classes in green, literals in red, reserved words in blue etc.

Re: code highlighting

Posted: Tue Aug 25, 2009 4:22 pm
by BeeJay
That would be a nice option - not that I'm offering to code the changes necessary to support this... besides I don't have access to the source for these new forums anyway....

Unfortunately global constants would just have to go class color green as the forums don't have the meta-data to know if the upper-case-first-letter "word" is a class name or a global constant name like the IDE does. :)

Cheers,
BeeJay.

Re: code highlighting

Posted: Wed Aug 26, 2009 1:26 am
by ghosttie
True, but it could highlight known classes and constants (i.e. Jade ones) correctly and leave unknown ones black

Re: code highlighting

Posted: Wed Aug 26, 2009 12:56 pm
by allistar
I have some old Jade code that does this to Jade method source. It's pretty straightforward and could be converted to PHP is someone wants to put in the effort.

Re: code highlighting

Posted: Thu Aug 27, 2009 1:56 am
by ghosttie
I'd be willing to give it a shot if we had confirmation from Jade that they were willing to install it in the forum

Re: code highlighting

Posted: Wed Sep 09, 2009 8:59 am
by admin
I'd be willing to give it a shot if we had confirmation from Jade that they were willing to install it in the forum
Yes, we will install it if someone is willing to write one. A Jade syntax highlighter function would need to be written in PHP and produce html output similar to http://php.net/manual/en/function.highlight-string.php, outputting only <span> and <br /> html tags in XHTML 1.0 Strict and use css classes for colorization.

The bbcode code tag could specify jade code as follows:
Thanks

Re: code highlighting

Posted: Thu Sep 10, 2009 1:50 am
by ghosttie
allistar, can you post your code highlighting code so I can take a look at it please?

Re: code highlighting

Posted: Thu Sep 10, 2009 9:19 am
by allistar
No problem, I'll try and find the Jade database this code is in and I'll attach the class that does this highlighting.

Re: code highlighting

Posted: Thu Sep 10, 2009 9:37 am
by allistar
Attached is a zipped class extract for a class that was designed to show exception details from an exception on a webpage (it is used for Jade systems exposed on the web using JHP). It should br fairly easy to get working by itself: call the "set" method passing in: (false, sourceCode, 0, "", 0, 0) and then call getDisplay to return the HTML version of the method. This doesn't use style sheets at all - it returns the old style <font...> etc. tags. It shouldn't be too difficult to modify it to work in PHP. All I ask is that the resultant PHP class be made available to all who want it.

Re: code highlighting

Posted: Thu Sep 10, 2009 9:37 am
by allistar
Apparently the "board attachment quota has been reached". Once this is fixed I'll upload the file, otherwise provide me with an email address and I'll email it instead.