I've recommended it before, and here it is again ;)...
I personally like the HTML_BBCodeParser package offered in PEAR. I was fooling around with this about a week ago and I liked how it made sure that all of the tags were closed and nested correctly, in other words it didn't just replace the BBCode markup, it made sure it was properly nested and all of that as well. I found it also was rather easy to fork with my own custom BB code syntax. In fact I modified the package rather painlessly to produce markup that uses all CSS, where appropriate, is accessible and is XHTML compliant.
If you want that package go to:
http://pear.php.net/HTML_BBCodeParser
It saved me the trouble of having to come up with complex regular expressions on my own. If you'd like to have a peek at the source code of my modified version of that package and the
JS that I use to apply the BBCode, drop me an email and I'll send you the source code. In fact the
JS that I used was based largely on the Snitz
JS used in this forum, it was very easy to optimize and customize. I just copied their libraries and made some modifications to reduce the amount of code necessary and wrapped it in PHP so that it is abstracted and easily applied to any textarea field.
Regards,
Rich
--
[
http://www.smilingsouls.net]
[
http://pear.php.net/Mail_IMAP] A PHP/C-Client/PEAR solution for webmail