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