# $Id: Parser.pm 284 2006-12-01 07:51:49Z chronos $ package BBCode::Parser; use BBCode::Util qw(:parse :tag); use BBCode::TagSet; use BBCode::Tag; use BBCode::Body; use Carp qw(croak); use strict; use warnings; our $VERSION = '0.34'; BEGIN { die "EBCDIC platforms not supported" unless ord "A" == 0x41; } =head1 NAME BBCode::Parser - Parses BBCode tags =head1 DESCRIPTION BBCode is a simplified markup language used in several online forums and bulletin boards. It originated with phpBB, and remains most popular among applications written in PHP. Generally, users author their posts in BBCode, and the forum converts it to a permitted subset of well-formed HTML. C is a proper recursive parser for BBCode-formatted text. =head1 OVERVIEW A C object stores various settings that affect the parsing process. Simple settings are typically set when the parser is created using L, but they can be queried using L and altered using L. See L for more information. In addition to the simple settings, specific BBCode tags (or classes of tags) can be permitted or forbidden, using L and L respectively. By default, the only forbidden tag is C<[HTML]>, which is normally a security violation if permitted. See L for a list of tag classes. Once the parser has been configured appropriately, parse trees can be created using the L method. The parse tree will consist of objects derived from L; the root of the tree will be a L object. Converting the parse tree to HTML is quite simple: call L on the root of the tree. Likewise, the parse tree can be converted back to BBCode by calling L. See L<"METHODS" in BBCode::Tag|BBCode::Tag/"METHODS"> to find out what other output methods are available. =head1 SETTINGS The following settings can be manipulated using L and L. =over =item css_prefix (Type: String; Default: "bbcode-") Many BBCode tags will add CSS classes as style hooks in the output HTML, such as C<<
...
>>. This setting allows you to override the naming scheme for those hooks. At the moment, more direct control of the CSS class names is not available. =item css_direct_styles (Type: Boolean; Default: FALSE) Certain style-related BBCode tags, such as [U] (underline) and [S] (strike-through) don't have a direct equivalent in modern XHTML 1.0 Strict. If this value is TRUE, then the generated HTML will use a C