![]() |
|
#1
|
||||
|
||||
Marking source code for a web pageDoes anyone know of a way to markup source code when posting on a web page? What I mean is, GIDForums has the special bbcode that marks up C, Java, Python, etc. source code so it's easy to read, just like an IDE. Is there a way to simulate this on a web page?
I've thought about using CSS but I'd still have to manually "tag" each item in the code. Could a server-side script do this? If so, how would the logic work? I don't see how you could put the source code on a page and tell a script to parse it (of course, my programming skills are lacking right now It's not critical that I get something to work. I just thought it would look better than having something that looks like the generic "code" you get from bbcode. I've looked online but haven't found anything. __________________
Start Programming with Python-A beginner's guide to programming and the Python language. ------------- Common Sense v2.0-Striving to make the world a little bit smarter. |
||||
|
#2
|
||||
|
||||
Re: Marking source code for a web pageWhat I do is use Regular Expressions to find the bbcodes within a post.
So assume a post like this is submitted Code:
The first step is to place a marker where the code was found and send the example code to the syntax highlighter class or function. At this stage, the text posted will look something like this Code:
and the string sent to the CPP syntax highlighter is Code:
The syntax highlighter will process this string and add the 'colouring' by inserting the appropriate html tags. After processing, it will look like PHP Code:
Just before you display the post on a web page, you run it by htmlspecialchars() and put the markers back... simple? __________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
|
#3
|
||||
|
||||
Re: Marking source code for a web pageSounds simple enough. I'll mess around with it and see what I can break.
Thanks for the info. __________________
Start Programming with Python-A beginner's guide to programming and the Python language. ------------- Common Sense v2.0-Striving to make the world a little bit smarter. |
Recent GIDBlog
Once again, no time for hobbies by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| User defined headers | davis | Miscellaneous Programming Forum | 6 | 16-Feb-2006 19:40 |
| Having a problem | Chuckles | Computer Hardware Forum | 19 | 13-Sep-2004 13:17 |
| Windows 2000 & NT source code leak | Garth Farley | Computer Software Forum - Windows | 3 | 26-Feb-2004 16:23 |
| web server in secure mode not connecting to http application | tcsasp | Apache Web Server Forum | 0 | 06-Nov-2003 01:08 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The