Re: Syntax Highlighter

From: Date: Sat, 28 Sep 2002 19:38:47 +0000
Subject: Re: Syntax Highlighter
References: 1  Groups: php.doc.chm 
Request: Send a blank email to php-doc-chm+get-539@lists.php.net to get a copy of this message
To integrate it into the manual, I have added 2 lines to the _script.js file. I added a call to ColorIt() in the bottom of defaultDisplayPage() and I also added document.write('<script src="_color_code.js"><'+ '/script>'); at the bottom of the _script.js file. however, if you want to script users or the preferences to be able to change the script colors, you will have to move this line above document.write('<script src="php_manual_prefs.js"><'+ '/script>'); In the case of a code example where code has not been highlighted, a call to CodeExample(number) will do the trick. the number is the example number, as is all ready set up. this is of course presuming that the example will have a id set up similar to the existing one. before CodeExample() is run, it is important to run ColorIt() as it sets up a much needed TextRange (ExampleRange). if ColorIt has not been run, this range can be set up manually. colors can be easily changed by moving "var CodeColors = new ColorIs("#000000","#CC0000","#B8860B","#006600","#0000CC");" to what ever script page is desired. NOTE: the default color for code examples must be black or bad things might happen. I thought that it would be wise to leave it up to script designers to make sure the script text was initially black in order to make the script faster. the fastest work around I can think of is adding a inline style tag to the examples that would override an external style sheet. Brendan "Knight" <knightemu@yahoo.com> wrote in message news:20020928185519.82582.qmail@pb1.pair.com... > ok, this is a complete php source highlighter written in js. it has been > tested with numerous examples from the php chm documentation on ie6 and ie5. > I have yet > to find any bugs except for the ones listed below. most of these bugs can be > fixed but at a slight speed decrease. none of the bugs are what I would call > serious. This js highlighter actually fixes some inconsistencies and small > bugs that exist the existing php highlighter. > > http://knightsweb.net/_color_code.zip > > the php source highlighter does not run as fast as hard coded pages do(at > least in machines with less powerful cpu's. it may actually increase the > speed with fast cpu's and large examples) but > never the less is not quite as fast as I would like it to be on my P1 200. > > it is my suggestion that as long as we find the source highlighter works > consistently, it > be used instead of the old one. I would also recommend that this highlighter > be > applied by default to the manual pages and off by default on the note pages. > If at all possible, an option to switch on-off the syntax highlighter for > ether section would be nice. if the ether section is disabled, a link should > be displayed to highlight the code example over top of the example. a good > place for it may be in the "copy to clipboard" tab. > > bugs - (reason for not fixing) > - probably the most serious problem is caused by js not acting like it > should. (where have I heard of this before?) it causes some dots to have the > wrong color eg. ".=" will make the dot blue(default) and "8.9" will cause > the > dot to be green(keyword). however in the majority of cases the dot displays > correctly.(speed) > - as you may notice when viewing the source highlighter, some key words that > are also links are not the right color. this only happens when an unneeded > <span> tag is inserted. but it does not matter as all span tags can be > safely > removed.(current tags) > - does not support heredoc string support fully. in the 4 or 5 simple > examples there is not really a big problem. (time, speed) > - does not have support for vars and constructs in echo construct. > (speed,time) > - does not color first $ green on something like ($$lake)... I think the > green dollar sign sitting next to the blue one looks stupid any ways. > (speed) > - does not support <script></script> php calls. if any one feels the need to > color the one line of code that exists in the one example that exists in the > php documentation, by all means uncomment the code to support it. (speed) > - in ie 5, some small code examples are not highlighted. (time, speed) > > Fixes over the default php source highlighter > - displays echo text constantly (sometimes was not coloring properly) > - colors "=" green in <?= $sally?> > - colors all examples (in ie6). does not leave behind some and color others > > possible improvement > I am thinking about changing the way the highlighter works (a little) right > now if you are using cast typing, what ever type may be in the green > brackets is also green eg. (string), (array), (bool). > I personally find it much easier to read with the inside text blue(or a > different color), and it would also decrease the time it takes for this > syntax highlighter to process. > > I would appreciate it if I could have some input on any or all of the above. > lets decide if we > are going to use it and if so, lets decide how many if any of the above > fixes and improvements we want to implement. > > I am not saying we should absolutely use this highlighter but it gives us > more > options to work with. > > btw. I would also highly recommend that we pre tags to remove the unneeded > &nbsp;'s and the <br>'s at the end of the line. this would not only decrease > the download time but would also decrease the display time and would speed > up this php syntax highlighter. > > Brendan > > > > > >

« previous php.doc.chm (#539) next »