Topic awaiting preservation: Make your own bbCode (Page 1 of 1) |
|
---|---|
Maniac (V) Mad Scientist From: :morF |
posted 05-22-2003 14:12
I know that a few asylumites over the years have made bbCode parsers, you know, things that will take a certain tag (like UBB code) and replace it with the appropriate HTML tag. Well the time has come when I need to do that and I cannot for the life of me get it to work. I had though just to do a recurring str_replace() that keeps searching through the text and each time it finds any of these tags it replacees it with it's HTML equivilant, but no...that doesn't seem to work...the damn tags are still there. |
Maniac (V) Inmate From: there...no..there..... |
posted 05-22-2003 16:39
not sure what language you want, but here is a php script that seems it will do it. |
Maniac (V) Mad Scientist From: 127 Halcyon Road, Marenia, Atlantis |
posted 05-22-2003 17:07
what do you know, I was working on this just last night in perl... here's what I got so far: code: #usr/bin/perl
|
Maniac (V) Mad Scientist with Finglongers From: Cell 53, East Wing |
posted 05-22-2003 17:17
This is what vBulletin does (with soe alterations by me to fit in with the GN): |
Maniac (V) Mad Scientist From: 100101010011 <-- right about here |
posted 05-22-2003 18:17
Theoretically what I would do (and on one project have done) is parse for anything within braces ([ ... ]) and then take the contents and check it against a list of possible replacements. If it fits then I'd do the replace. If it doesn't then I'd print out the brackets as is. |
Paranoid (IV) Inmate From: New Jersey, USA |
posted 05-23-2003 00:30
Here's what I'm using most of which is from phpBB.
', '</list>', $description); |
Paranoid (IV) Inmate From: California |
posted 05-23-2003 03:34
Petskull: You might find it faster to read in the whole file and make one pass per regex instead of one pass per line for each regex. File I/O and expressions are expensive. Here is a sample of the code I use to read in a file: code: open HTML, "<$file" or die "Could not read-open $file. Reason: $!";
|
Paranoid (IV) Mad Scientist with Finglongers From: Germany |
posted 05-23-2003 07:58
actually *real* ubb code parsing is a lot more complicated than just a couple dozen regexps... |
Maniac (V) Mad Scientist From: 127 Halcyon Road, Marenia, Atlantis |
posted 05-24-2003 08:13
Piper... smart stuff.. I did get a little caught on this: code: #usr/bin/perl
|