Our BBCode parser,
patBBCode, ist available as v1.0.0beta. This small library is based on a SAX parser, and retrieves all tags with just one regular expression. The tag transformation is then done by filter objects, or patBBcode itself in case of 'basic' tags without attributes.
A complete
documentation is available as well as a series of
examples also included in the package for a quick start.
Some are already familiar with patBBCode, but with this release there are a few new things. Filter classes can now trigger their own user errors, e.g. if a vital attribute is missing. The biggest addition, however, is the Describer helper class: it enables you to describe an existing patBBCode object by retieving information about all available tags. This can be used to automatically generate a tag guide which you can retrieve in several output formats by means of a specific Driver object. The following bit of code generates an HTML table with a list of tags and their function:
// create the Describer
$descr =& patBBCode::createDescriber();
// create the driver
$driver =& $descr->createDriver( 'HTML' );
// tell the describer to use the driver
// $descr->setDriver( $driver );
// and display the documentation
echo $descr->describe( $BBCode );
You can view the result
here - this is included in the examples collection of the package. For the moment, the HTML driver is very simple, but I intend to add a patTemplate driver which will give you total layout control. Another feature worth noting: the Describer respects the locale you set in the patBBCode object you describe