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

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

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



Subject: [b]foo[/B] not working when providing a callback [PATCH]
Patch with tests attached.
Subject: Parse-BBCode-casing.patch
diff -Nru Parse-BBCode-0.13/lib/Parse/BBCode.pm Parse-BBCode-0.13-nicomen/lib/Parse/BBCode.pm --- Parse-BBCode-0.13/lib/Parse/BBCode.pm 2011-08-19 12:06:24.000000000 +0000 +++ Parse-BBCode-0.13-nicomen/lib/Parse/BBCode.pm 2011-09-14 13:28:51.000000000 +0000 @@ -548,7 +548,7 @@ else { #warn __PACKAGE__.':'.__LINE__.": noparse, find content\n"; # just search for closing tag - if ($after =~ s# (.*?) (\[ / $tag \]) ##xs) { + if ($after =~ s# (.*?) (\[ / $tag \]) ##ixs) { my $content = $1; my $end = $2; #warn __PACKAGE__.':'.__LINE__.": CONTENT $content\n"; diff -Nru Parse-BBCode-0.13/t/16_casing.t Parse-BBCode-0.13-nicomen/t/16_casing.t --- Parse-BBCode-0.13/t/16_casing.t 1970-01-01 00:00:00.000000000 +0000 +++ Parse-BBCode-0.13-nicomen/t/16_casing.t 2011-09-14 13:37:43.000000000 +0000 @@ -0,0 +1,54 @@ +use Test::More tests => 12; +use Parse::BBCode; +use strict; +use warnings; + +my $repl = 'repl'; + +my $p = Parse::BBCode->new({ + tags => { + b => $repl, + }, + } +); + +my $pns = Parse::BBCode->new({ + tags => { + b => $repl, + }, + strict_attributes => 0, + } +); + +my @tests = ( + [ qq#[b]a[/b]#, $repl], + [ qq#[b]a[/B]#, $repl], + [ qq#[B]a[/B]#, $repl], + [ qq#[B]a[/b]#, $repl], + + [ qq#[b=foo]a[/b]#, $repl], + [ qq#[b=foo]a[/B]#, $repl], + [ qq#[B=foo]a[/B]#, $repl], + [ qq#[B=foo]a[/b]#, $repl], + + [ qq#[b haha haha]a[/b]#, $repl, undef, $pns], + [ qq#[b haha haha]a[/B]#, $repl, undef, $pns], + [ qq#[B haha haha]a[/B]#, $repl, undef, $pns], + [ qq#[B haha haha]a[/b]#, $repl, undef, $pns], +); + +for my $test (@tests) { + my ($text, $exp, $forbid, $parser) = @$test; + $parser ||= $p; + if ($forbid) { + $parser->forbid($forbid); + } + my $parsed = $parser->render($text); + #warn __PACKAGE__.':'.__LINE__.": $parsed\n"; + s/[\r\n]//g for ($exp, $parsed); + $text =~ s/[\r\n]//g; + cmp_ok($parsed, 'eq', $exp, "parse '$text'"); +} + + +
Am Mi 14. Sep 2011, 09:44:22, NICOMEN schrieb: Show quoted text
> Patch with tests attached.
thanks, I fixed it although I didn't understand what you mean with callback here...