1 (edited by Reines 2007-01-08 15:59)

Topic: Basic syntax colouring with line numbers

Firstly, i realise there are a bunch of syntax colouring mods out there, but I like to make my own mods instead, i like to know exactly how things work and its good practice. You can see a demo, along with the instructions here: http://www.syi.cc/viewtopic.php?pid=521483#p521483

I am not properly releasing this mod yet, as it has afew things in it I would like to get sorted first.

- Escape characters are not handled properly within strings, for example in line 20 in the first code tag.

'/(\'.*\')/U'

This of course should be continuously coloured, as the whole thing is ment to be a string.

- If the line is too long, it pushes onto the next line, eg.

01.
$text .= '</p><div class="codebox"><div class="incqbox"><h4>'.$lang_common['Code'].':</h4><div>'."\n".parse_code($inside[$i])."\n".'</div></div></div><p>';

- Keywords are highlighted even if part of a word. Eg:

$newly

I assume in regex there must be an easy enough way to specify it must not be surounded by alphanumeric chars? Ill look into it later on, as I said, my regex isn't top.

- I would like to have the current line being hovered over highlighted. This is simple enough for FF, as you can use li:hover in css. However in IE :hover is only defined for a tags, with a href property. Is there some way around this?

Really I am posting this, hoping for some help fixing these problems, to be fair I haven't actually tackled either properly yet, but my regex knowledge isn't amazing (for the first one is there some way to say the ending tag must not be followed by a \?).

Any input is appreciated.

Thanks

2

Re: Basic syntax colouring with line numbers

Looks great so far, Reines! Keep up the good work wink

Re: Basic syntax colouring with line numbers

\b$keyword\b will match the keywords correctly

Re: Basic syntax colouring with line numbers

MadHatter wrote:

\b$keyword\b will match the keywords correctly

Thank you (:

5 (edited by Reines 2007-01-08 17:30)

Re: Basic syntax colouring with line numbers

Damnit, I just noticed the line numbers aren't working at all in IE... Any suggestions why not? It's just an ordered list with decimal list style :s

Edit: Nevermind, IE was ignoring the inside command, and putting the numbers outside the list (ie. under the containing div).

Re: Basic syntax colouring with line numbers

They're working in IE7. And in IE6.

Re: Basic syntax colouring with line numbers

elbekko wrote:

They're working in IE7. And in IE6.

Yeh i sorted it, just had change FF to use outside too and set a left margin so they came out from under the div.

Re: Basic syntax colouring with line numbers

Yeah, read your post after I posted mine >=/ Silly VMWare taking so long to start tongue

Re: Basic syntax colouring with line numbers

Given up on this ):

Found a much nicer one already made so decided to use that, ive requested this thread be locked/deleted.

Re: Basic syntax colouring with line numbers

or you could point the one you like and why do you think is nice smile

Re: Basic syntax colouring with line numbers

Closed at Reines's request smile
pedrotuga: send Reines an email smile