Page 1 of 1
javascript source highlighter
Posted: Sat Oct 27, 2007 1:32 pm
by demebeu
Hi all,
Given that the problem's forum has a lot of source code for the solutions of any problem, I think it would be nice if you could use a javascript source code highlighter like
http://shjs.sourceforge.net for example. This could really help reading and understanding other people solutions. I remember seing something simlar on google code, but right now I cannot find it.
Re: javascript source highlighter
Posted: Sat Oct 27, 2007 9:18 pm
by Mgccl
GeShi(PHP), dp.syntaxhighlighter are other things euler could consider
Re: javascript source highlighter
Posted: Sun Oct 28, 2007 9:08 pm
by euler
Thanks for the original suggestion, demebeu.
As you will see I have implemented a generic syntax highlighting feature and I went with GeShi in the end - many thanks, Mgccl; a splendid suggestion! Although shjs did a lovely job, some members have JavaScript disabled and would miss out on the lovely rendering it was offering. Whereas GeShi doesn't depend on the client's browser configuration and is entirely done by server side scripting.
It took a lot of work to get it to work and required a complete rewrite of the parsing routine I was using for the [ code ] elements. I'm really pleased with the results, but if anyone has any thoughts please let me know what you think.
Re: javascript source highlighter
Posted: Sun Oct 28, 2007 10:30 pm
by stijn263
it looks really nice. i see you fixed the [ i] problem in the [ code] box. one thing tho, if someone doesn't use an enter in his code, the screen gets wider (don't know how to explain this in english, but i hope you know what i mean). other than that, it looks great

Re: javascript source highlighter
Posted: Sun Oct 28, 2007 10:35 pm
by euler
Yes, the use of arrays containing the variable "i" in the [ code ] tags was a problem (b, r, and g would have caused similar problems). I had to improvise with some mind-boggling preg expressions - not my area at all - and if I'm honest I still don't fully understand why it works; it seems a bit of a dark art.
You're right about the problem with long lines of non-breaking text. Previously I made use of a "word wrap" function, but it was rather resource hungry so I decided to remove it to help streamline the process. I just hope that members will take time to ensure that they place line breaks at the end of long lines.
Re: javascript source highlighter
Posted: Mon Oct 29, 2007 8:39 am
by demebeu
Wow, pretty nice work. Sorry to ruin you weekend.
Re: javascript source highlighter
Posted: Mon Oct 29, 2007 1:05 pm
by stijn263
You're right about the problem with long lines of non-breaking text. Previously I made use of a "word wrap" function, but it was rather resource hungry so I decided to remove it to help streamline the process. I just hope that members will take time to ensure that they place line breaks at the end of long lines.
closely related to this problem, this is what joshbowman suggested in the problem 163 forum: (i hope he doens't mind me copying his text)
joshbowman wrote:Also it is painfully obvious that a feature for automatic hiding of code is needed in the forum. Click to expand... Should be some simple script and a new tag or two?
Euler?
Re: javascript source highlighter
Posted: Mon Oct 29, 2007 7:04 pm
by euler
Thanks for bringing that suggestion to my attention,
henk263. It was a great idea and I've just added it.

Re: javascript source highlighter
Posted: Mon Oct 29, 2007 8:32 pm
by demebeu
It should be easy to somehow be able to expand all code snippets at once. I for one, after solving one problem, like to look at others people code and now I have to do a lot of clicking to do just that. Why not be able to just click once and see all source code?
And I dont know about you, but all those blue colors just don't seem to match. Like the blue on the header with the blue on the problems / forum table. I must admit I usually use a program to match my colors (something like
http://www.colorschemer.com/online.html).
Re: javascript source highlighter
Posted: Tue Nov 20, 2007 12:59 pm
by RoundTower
the code highlighter doesn't work very well with the ' character (single quote). A lot of times particularly in LISP code there is an open quote but no closing quote is used, and the rest of the program gets highlighted incorrectly.
Re: delphi source highlighter
Posted: Wed Dec 26, 2007 11:52 am
by ThomasH
I just noticed the code highlighting for delphi and I feel, it helps a lot. Thank you very much Euler.