View Single Post
Old 12-05-2004, 05:39 PM   #1 (permalink)
Rafkin
Registered User
 
Rafkin's Avatar
 
Join Date: Mar 2004
Posts: 20
Rafkin is on a distinguished road
Question Syntax Highlighter

Hi, I am building a page, that has among other things, script snipplets and how-to's for a script language built for a game. (it scripts events and does other things for map creation)

I plan to host the raw script in ascii form in the database, but upon displaying it, along with a text box that they can copy from, I want to show the highlighted snipplet.

So, what I need is a function into wich I can submit a string, and have it highlight the syntax for me. Variables in one color, numbers in another, etc, etc.

Problem is, I have no idea how to even start on this, with php. Anyone able to give me some pointers on how I can create this function?

For refference, a sample code I have created for show, looks like this.

Code:
* This comment brought to you by McDonalds. Have you had your break today?
(0:7) When somebody moves into position (24,43),
   (1:4) and they bump into a Furre,
      (3:4) within the rectangle (%position1) - (%position2),
         (4:1) only where the floor is type 26,
            (5:4) place object type @3.
            (5:200) emit message {bunch of text} to whoever set off the trigger.
The Comments are lines that start with *, % denotes variables, and @ denotes a pointer. the strings inside the {}'s i need to highlight, as well as the numbers. And I'd like to make sure the lines are indented properly.

Can anyone help?
Rafkin is offline   Reply With Quote