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: 71018
Status: resolved
Priority: 0/
Queue: Parse-BBCode

People
Owner: Nobody in particular
Requestors: mendoza [...] pvv.ntnu.no
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.13
Fixed in: 0.13_001



#!/usr/bin/perl use Test::More qw(tests 2); use Parse::BBCode; my $p = Parse::BBCode->new({ tags => { b => 'block:<b>%s</b>', i => 'block:<i>%s</i>', }, close_open_tags => 1, }); my @code = ('[b][i]text', '[b][i]text[/b]'); foreach(@code) { is($p->render($_), '<b><i>text</i></b>', qq{Test that auto closing of open tags is consistent}); } I have an issue, it seems, with auto closing tags, please try the above tests, and notice that it doesn't try to close an inner tag if an outer tag is getting closed. I believe this should happen?
fr. 16. sep. 2011 08.50.20 skrev NICOMEN: Show quoted text
> #!/usr/bin/perl > > use Test::More qw(tests 2); > use Parse::BBCode; > > my $p = Parse::BBCode->new({ > tags => { > b => 'block:<b>%s</b>', > i => 'block:<i>%s</i>', > }, > close_open_tags => 1, > }); > > my @code = ('[b][i]text', '[b][i]text[/b]'); > > foreach(@code) { > is($p->render($_), '<b><i>text</i></b>', qq{Test that auto closing
of Show quoted text
> open tags is consistent}); > } > > > I have an issue, it seems, with auto closing tags, please try the
above Show quoted text
> tests, and notice that it doesn't try to close an inner tag if an
outer Show quoted text
> tag is getting closed. I believe this should happen?
This patch seems to do the trick: diff -r Parse-BBCode-0.13/lib/Parse/BBCode.pm Parse-BBCode-0.13-nicomen/ lib/Parse/BBCode.pm 438c438,445 < $callback_found_tag->($_) for $try->_reduce; --- Show quoted text
> if ($self->get_close_open_tags) { > $f = $try; > unshift @not_close, $try; > if (@opened) { $opened[-1]->add_content
(''); } Show quoted text
> $self->_finish_tag($try, '[/'. $try- >get_name() .']'); > } else { > $callback_found_tag->($_) for $try- >_reduce; > }
Also there seems to be an issue with closing open tags, and not parsing the content. use Test::More tests => 6; use Test::NoWarnings; use Parse::BBCode; use strict; use warnings; my $p = Parse::BBCode->new({ tags => { b => '<b>%s</b>', i => '<i>%s</i>', noparse => { code => sub { my ($parser, $attr, $content, $attribute_fallback) = @_; return "${$content}"; }, parse => 0, }, }, close_open_tags => 1, }); my %tests = ( '[b][i]text' => '<b><i>text</i></b>', '[b][i]text[/b]' => '<b><i>text</i></b>', '[b][i]text[/i]' => '<b><i>text</i></b>', '[b][noparse]<i>text</i>[/b]' => '<b><i>text</i></b>', '[noparse][b]<i>text</i>[/b]' => '[b]<i>text</i>[/b]', ); while (my ($code, $exp) = each %tests) { my $tree = $p->parse($code); is($p->render_tree($tree), $exp, qq{Test that closening of opening tags is consistent}); } I have a patch for this too if you are interested
Am Fr 16. Sep 2011, 08:50:20, NICOMEN schrieb: Show quoted text
> I have an issue, it seems, with auto closing tags, please try the above > tests, and notice that it doesn't try to close an inner tag if an outer > tag is getting closed. I believe this should happen?
thanks! that's right, and I applied your patch. I'm looking into the other tickets now and hope I can make a release soon. regards, tina
Am Di 20. Sep 2011, 06:46:44, NICOMEN schrieb: Show quoted text
> Also there seems to be an issue with closing open tags, and not parsing > the content.
uh, yes, that's tricky. I fixed it. The fix doesn't look very elegant but the test suite suceeds =)