The problem I have come across is - there are so many out there and many people commenting it’s hard to find a good one so I’m a bit lost. I need a bbcode parser for a community site with the following requirements:
support for all common bbcode tags including nested quoting, embedding images, youtube videos
automatic link recognition and shortening long links for display
smileys
quite secure against malicious html/js injection
error free when fed malformed content
a nice addition would be well structured OO interface and configurable (like custom tags, disallowing chosen tags, etc.)
I could write my own function with a few regex expressions but I’d rather use something mature and tested. If anyone has had good experience with a library like that I’d be happy to hear.
I decided to try out NBBC first and have now only a few first impressions:
Very easy to install and use.
I wanted to chage the default English text for [ quote ] like “XXX wrote” and “Quote:” - it was hard-coded. Fortunately, I was able to easily overwrite the whole method for the [ quote ] tag. However, some better customization would be welcome.
I wanted to set default target=“_blank” for links - no problem.
I wanted to enable link auto-detection, it was very easy but the class is buggy here because it detects too much so when I use the [ url ] tag for link then I get two nested <a> tags. I had to use a regex afterwards to get rid of that.
I cannot find a way to shorten long links automatically, certainly it can be done but it’s not very straightforward and may require a bit of hacking (=overwriting methods).
The conversion seems to be pretty fast.
Generally, the code looks well written (but still for php 4) and separated in different classes. However, I think it would need more attention from the developer to fix some bugs and get a few small features more polished.
When I have time I will try StringParser but for now I have to carry on with my project and focus on other things. Do you have any experience with StringParser regarding the points above?