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

People
Owner: Nobody in particular
Requestors: mark [...] thisaintnews.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.09
Fixed in: 0.10



Subject: Tag format
Hi,

I like this module, it does everything I need and it does it well :)
I did need to change the tag format though, so it would accept tags in the following format:

[foo bar=foobar]       instead of        [foo=barfoo bar=foobar]

I was gonna hack this coz its just a regex change on line 346 from

^(=[^\]]*)?]     to     ^([^\]]*)?]

I wasn't sure, so i added it as an option. You can pass in the option on instantiation

tag_validation => qr/some_regex/

Thought I'd share. See the attached diff for the changes

Mark
Subject: diff.patch
--- old/BBCode.pm 2009-05-21 12:44:18.000000000 +0100 +++ new/BBCode.pm 2010-01-04 22:36:35.760872130 +0000 @@ -6,7 +6,7 @@ use base 'Class::Accessor::Fast'; __PACKAGE__->follow_best_practice; __PACKAGE__->mk_accessors(qw/ tags allowed compiled plain strict_attributes - close_open_tags error tree escapes /); + close_open_tags error tree escapes tag_validation /); use Data::Dumper; use Carp; @@ -14,6 +14,7 @@ my %defaults = ( strict_attributes => 1, + tag_validation => qr/^(=[^\]]*)?]/, ); sub new { my ($class, $args) = @_; @@ -343,7 +344,8 @@ if ($after) { # found start of a tag #warn __PACKAGE__.':'.__LINE__.": find attribute for $tag\n"; - if ($after =~ s/^(=[^\]]*)?]//) { + my $validation_regex = $self->get_tag_validation; + if ($after =~ s/${validation_regex}//) { my $attr = $1; $attr = '' unless defined $attr; #warn __PACKAGE__.':'.__LINE__.": found attribute for $tag: $attr\n";
Am Mo 04. Jan 2010, 17:50:32, https://me.yahoo.com/a/ CZn6tUAWy5.qIAhRjsuEilye5WxYoA--#a9afc schrieb: Show quoted text
> I did need to change the tag format though, so it would accept tags
in the Show quoted text
> following format: > > [foo bar=foobar] instead of [foo=barfoo bar=foobar]
[...] Hi, I'm not sure if tag_validation is the best option or if I should rather add a boolean flag that says if there should be a first attribute behind the tag name or not. On the other hand, I also have a case where I have non standard bbcode that would need a custom regex and maybe a callback that defines what to do with the captured values. I have to think about it... Thanks for the request so far, tina
I added a new option "direct_attribute" in version 0.10. If set to 0, the syntax is [tag attr=val] instead of [tag=val attr=val]. That allowed me to parse the attribute string itself correctly. Do you think that's ok? Would be glad if you can try it out and tell if that's a sufficient solution.
Subject: Re: [rt.cpan.org #53353] Tag format
Date: Mon, 14 Jun 2010 19:54:24 +0100
To: bug-Parse-BBCode [...] rt.cpan.org
From: mark <mark [...] thisaintnews.com>
yeah as soon as its up it'll test it out. good work :) Mark On 14 June 2010 19:37, Tina Muller via RT <bug-Parse-BBCode@rt.cpan.org>wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=53353 > > > I added a new option "direct_attribute" in version 0.10. If set to 0, > the syntax is [tag attr=val] instead of [tag=val attr=val]. > > That allowed me to parse the attribute string itself correctly. > > Do you think that's ok? Would be glad if you can try it out and tell if > that's a sufficient solution. >
Subject: Re: [rt.cpan.org #53353] Tag format
Date: Tue, 15 Jun 2010 20:20:10 +0100
To: bug-Parse-BBCode [...] rt.cpan.org
From: mark <mark [...] thisaintnews.com>
Tina, this is perfect! Thanks very much [?] On 14 June 2010 19:54, mark <mark@thisaintnews.com> wrote: Show quoted text
> yeah as soon as its up it'll test it out. > > good work :) > > Mark > > > On 14 June 2010 19:37, Tina Muller via RT <bug-Parse-BBCode@rt.cpan.org>wrote: >
>> <URL: https://rt.cpan.org/Ticket/Display.html?id=53353 > >> >> I added a new option "direct_attribute" in version 0.10. If set to 0, >> the syntax is [tag attr=val] instead of [tag=val attr=val]. >> >> That allowed me to parse the attribute string itself correctly. >> >> Do you think that's ok? Would be glad if you can try it out and tell if >> that's a sufficient solution. >>
> >
Download 328.png
image/png 569b
328.png