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;
> }