The Ermarian Network

Extensible BBCode

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 has the problem of utter rigidity: Adding or modifying a tag requires editing the source of the module. 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 native BBCode module of Drupal. I use this module on all my sites, and it works like a dream.

SVN

http://svn.ermarian.net/drupal/modules/xbbcode

Releases