Skip Menu |

This queue is for tickets about the Parse-BBCode CPAN distribution.

Maintainer(s)' notes

If you have any wishes, feel free to create a ticket.

Plans:

I would like to add callbacks to the parser so that you can gather some information about specific tags and ideally can manipulate them during parsing.

But there are already enough informations to create a download link for code tags, for example. See example/code_download.pl.

Parse::BBCode is now hosted on github, so for bug reports also check https://github.com/perlpunk/Parse-BBCode

Report information
The Basics
Id: 55732
Status: resolved
Priority: 0/
Queue: Parse-BBCode

People
Owner: Nobody in particular
Requestors: redneb [...] gmx.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.12



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.
Hi, Am Sa 20. Mär 2010, 02:25:50, redneb@gmx.com schrieb: Show quoted text
> 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:
[...] Show quoted text
> 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.
Yes, you're right, thanks for your report. I have to think about the implementation, how to make it generic...
In version 0.10, I remove at least the line breaks behind [list], before [/list], and at the end of the [*] tags. That should at least solve the problem with invalid XHTML. For removing newlines around the tag I haven't had an idea yet how to implement that. I need to have some callbacks and in the tag rendering I need to have information about the current outer tag. Do you have an idea how that could look like? Until then you have the possibility to get the parse tree and manipulate it yourself by going through it and search for list tags. I need this feature myself, have seen that superfluous line break and it's annoying...
Oh sorry, was talking nonsense. My changes won't remove <br> tags. But I have an idea about how to do the callbacks now.
I changed it (version 0.12) so that the first and last linebreak in a block tag are removed. It's more difficult to remove linebreaks outside of the tag, and for some tags a linebreak before seems important so I'm not sure if a change would make sense in all cases. For this I would really need parsing callbacks (which I still plan to implement). I hope the changes I made help a bit.