On Sun Sep 19 07:03:10 2010, TINITA wrote:
Show quoted text> Hi,
>
> if I wanted to use a bbcode to html converter in a public web forum,
> for example, I would not want to ceate it invalid HTML. Unbalanced
HTML
Show quoted text> tags for example. They could break the whole layout I guess.
>
>
> Is there an option to prevent that? I believe the reason for the
broken
Show quoted text> HTML is that the bbcode tags are parsed independently, so an [i] or
an
Show quoted text> [/i] is replaced by <i> or </i> no matter if there is an opening or
and
Show quoted text> tag at all.
>
> thanks
Lets not try to fool people in making them think your really going to
use my module for a real forum.
http://search.cpan.org/~tinita/ the
maintainer of Parse::BBCode. LOL
Yes 3.00 has settings that can be changed to not allow unbalanced tags.
But if you can deal with the unbalanced tags by moderating the web
forum then AUBBC will run a lot faster.
By using this method you can loos tags like code/c, url, email, quote,
img/left/right, center/left/right, and other tags the aubbc setting can
support.
Build your own tags will not convert unbalanced tags and this example
below has a few tags but not all. The rest you can make.
Example:
use AUBBC;
my $aubbc = AUBBC->new;
$aubbc->settings(aubbc => 0,);
my @other_tags =
('b','i','big','small','p','pre','sup','sub','h1','h2','h3','h4','h5','h
6');
foreach my $tag (@other_tags) {
$aubbc->add_build_tag(
name => $tag,
pattern => 'all',
type => 2,
function =>'main::other_tags', # use main:: or Module_Name:: .
);
}
my $bbcode = "[i] italic [b]bold[/b] end";
my $html = $aubbc->do_all_ubbc($bbcode);
print $html; # Output: [i] italic <b>bold</b> end
sub other_tags {
my ($tag_name, $text_from_AUBBC) = @_;
($tag_name)
? return "<$tag_name>$text_from_AUBBC</$tag_name>"
: return '';
}
# End
Maybe the next update I will change the tags in aubbc to not allow
unbalanced tags, but for now this can be the work around.