The Ermarian Network

XBBCode

Description

XBBCode is a new approach to parsing BBCode. Most simple implementations limit themselves to String replacements like

s/[i]/<i>/g

or at most regular expressions. However, this approach is highly inflexible: Adding or modifying a tag requires editing the source of the module, adding new string replacements or expressions. For example, there are several ways to italicize. <em> is better than <span style="italic"> for semantic reasons, and <i> needs to be done away with once and for all anyway. And wouldn't it be nice to be able to add new highly specific tags - say, [rfc=1149] linking to ietf.org's RFC pages?

Extensible BBCode allows all this by using a flexible parsing model. It loads tags through a hook from other modules (and its own modules from a database). A tag is in the form of

name: wikipedia replace with: <a href="http://www.wikipedia.org/wiki/{content}">{content}</a>

It also allows dynamic parsing (meaning code evaluation in the replacing text).

And here's the thing: In spite of the additional overhead, it is not noticeably slower than the static BBCode module using regular expressions. I use this module on all my sites.

SVN

Drupal 7
http://svn.ermarian.net/drupal/modules/xbbcode/trunk/xbbcode
Drupal 6
http://svn.ermarian.net/drupal/modules/xbbcode/branches/DRUPAL-6/xbbcode
Drupal 5
http://svn.ermarian.net/drupal/modules/xbbcode/branches/DRUPAL-5/xbbcode

Releases

License

Like Drupal, this addon is licensed under the GNU General Public License, version 2 and later. That means it is entirely free to download, use and modify, and it and all derivatives may be distributed by everyone under these terms.