Subject: | Some line breaks should be ignored |
Date: | Sat, 20 Mar 2010 02:25:27 -0400 |
To: | bug-Parse-BBCode [...] rt.cpan.org |
From: | redneb [...] gmx.com |
The are some cases where Parse::BBCode converts a line break into a
<br/> and that makes the output look ugly or even invalid as (X)HTML
code. For example, the following (bb)code:
aaa
[list]
[*]bbb
[*]ccc
[/list]
ddd
(which btw I think is the most natural way to write a list) produces the
following output:
aaa<br />
<ul><br />
<li>bbb<br />
</li><li>ccc<br />
</li></ul><br />
ddd
The problem here is that the second <br/> is not allowed by the XHTML
syntax and also introduces a big gap between "aaa" and the list. There
is also a similar gap issue with the last <br/>.
I think the easiest way to fix this problem would be by discarding one
line break before and after the opening and closing tag of a block
element (such as [list], [*], [quote] etc). So for example, in the
string "aaa\n[quote]\nbbb\n[/quote]\nccc", all 4 "\n" should be
discarded.
I tried several different examples and I think in all cases this rule
produces a more natural output which is also closer to that of other
bbcode parsers.