Skip to content Skip to sidebar Skip to footer

Simple Bbparser In Php That Lets You Replace Content Outside Tags

I'm trying to parse strings that represent source code, something like this: [code lang='html'] <div>stuff</div> [/code]
stuff

Solution 1:

HTML Purifier http://htmlpurifier.org/

But you are facing same issues just like in your 20 previous questions.

Solution 2:

Do you guys know a BB parser class written in PHP that I can use for this, instead of regexes?

There's the BBCode PECL extension, but you'd need to compile it.

There's also PEAR's HTML_BBCodeParser, though I can't vouch for how effective it is.

There are also a few elsewhere, but I think they're all pretty rigid.

I don't believe that either of those do what you're looking for, with regard to having a callback for tag contents (and then @webarto is totally correct in that HTMLPurifier is the right tool to use when processing the contents). You might have to write your own here. I've previously written about my experiences doing the same that you might find helpful.

Post a Comment for "Simple Bbparser In Php That Lets You Replace Content Outside Tags"