javascript source highlighter
-
demebeu
- Posts: 4
- Joined: Sat Oct 27, 2007 1:25 pm
javascript source highlighter
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.
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.
-
Mgccl
- Posts: 6
- Joined: Mon Oct 15, 2007 1:11 am
Re: javascript source highlighter
GeShi(PHP), dp.syntaxhighlighter are other things euler could consider
- euler
- Administrator
- Posts: 5095
- Joined: Sun Mar 05, 2006 4:49 pm
- Location: Cheshire, England
- Contact:
Re: javascript source highlighter
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.
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.

impudens simia et macrologus profundus fabulae
- stijn263
- Posts: 1505
- Joined: Sat Sep 15, 2007 11:57 pm
- Location: Netherlands
Re: javascript source highlighter
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 
- euler
- Administrator
- Posts: 5095
- Joined: Sun Mar 05, 2006 4:49 pm
- Location: Cheshire, England
- Contact:
Re: javascript source highlighter
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.
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.

impudens simia et macrologus profundus fabulae
-
demebeu
- Posts: 4
- Joined: Sat Oct 27, 2007 1:25 pm
- stijn263
- Posts: 1505
- Joined: Sat Sep 15, 2007 11:57 pm
- Location: Netherlands
Re: javascript source highlighter
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)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.
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?
- euler
- Administrator
- Posts: 5095
- Joined: Sun Mar 05, 2006 4:49 pm
- Location: Cheshire, England
- Contact:
Re: javascript source highlighter
Thanks for bringing that suggestion to my attention, henk263. It was a great idea and I've just added it. 

impudens simia et macrologus profundus fabulae
-
demebeu
- Posts: 4
- Joined: Sat Oct 27, 2007 1:25 pm
Re: javascript source highlighter
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).
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).
-
RoundTower
- Posts: 1
- Joined: Tue Nov 20, 2007 12:55 pm
Re: javascript source highlighter
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.
-
ThomasH
- Posts: 117
- Joined: Sun Mar 26, 2006 8:41 am
- Location: Berlin, Germany
Re: delphi source highlighter
I just noticed the code highlighting for delphi and I feel, it helps a lot. Thank you very much Euler.