It's regular expression :(
Here is how i've made it so far:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/txtforum1/txtforum1/view_topic.php?rev=1.20&content-type=text/vnd.viewcvs-markup (look at function ubbc_tag())
But the problem is if i type nasted tags ([quote] text[quote]text[/quote]text[/quote]) it will parse only first [tag].And not just for [quote] but for all ubbc code.
I've try to use some class like:http://www.phpclasses.org/browse.html/package/951.html but it dosen't support close tag...
I give up .....
Did you look at other projects like phpBB yet?
i've take a look at phpBB one.
but they design they code for phpBB and not for others :(
What do you think about this like solution:
You have generic function for parsing whatever UBBC tags or HTML if you like. First you can count how many times does [tag] repeats in text and then add iteration to change it with regexp. In first pass it will fetch most wider tags, and in next pass it will fetch neasted tag and so one...
Another solution is to fetch the first and last character of the UBB code and than iterate for all characters between them.
In general, I donot recommend you using of regexps for this. I donot know what does phpBB use, but as this code is executes on every post display, with many posts and many users this can be slow part of code.
Danilo Segan left nice and handy parser on Elitesecurity.org web forums so I am giving you an URL, look at that it is very powerful becouse it adds automatic closing of tags, some checkers and the best of all, you can addopt it for using with SGML sintax in against of UBBC one.
(you have examples too on that link)
I hope this helps you.
I've just checked Danilos code and it dosen't help...
It have lot of problems and i don't like the way he code it. Perhaps the best solution for this is to take somebody else class and to marge it with txtforum.
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.