Possible bug in HTML::BBCode?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View


While using the HTML::BBCode module (version 1.03 from CPAN), I noticed
something when using lists while the linebreaks option is true. Have a
look at the following example:


use strict;
use warnings;
use HTML::BBCode;

my $bbc = HTML::BBCode->new({
  no_html => 1,
  linebreaks => 1 });

my $bbcode=<<'BBCODE';
Some colors:

print $bbc->parse($bbcode);

this will output:

Some colors:<br />
<ul><br />
 <li> Red<br />
 </li><li> Blue<br />
 </li><li> Yellow<br />
</li></ul><br />

This would add a total of 2 newlines between the "Some colors" and the
actual list, not including the margins/paddings set with CSS. This will
also add a newline after every item, while - depending on your CSS -
this is done automatically. In most situations, this won't be a
problem, but it might also be considered as a possible bug.
The following output would be prefered:

Some colors:<br />
 <li> Red
 </li><li> Blue
 </li><li> Yellow
</li></ul><br />

Or, even better in my case - also delete the linebreak after the "Some
colors:" - but I don't think that's really urgent.
Currently, the only workaround I found is to remove the linebreaks from
the original BBCode, but this will look pretty nasty for large lists.

Is this a known bug? Or is it a feature? Are there other (prettier)
workarounds I didn't see?

Greets, YorHel

Re: Possible bug in HTML::BBCode?

YorHel wrote:
Quoted text here. Click to load it

Ok, since I haven't got any replies, but still wanted some results, I
modified the module a little, so the list-tag-output would be as I
expected. For the people interested in the changes (from version 1.03
of HTML::BBCode from CPAN), here's the output of diff:

<    $content =~ s|\[\*\]([^(\[]+)|<li>$1</li>|gs;
Quoted text here. Click to load it

As you can see, it's a small and ugly modification, but it works fine -
for me at least :)

Greets, //YorHel

Site Timeline