--- BBCode.pm-orig 2007-06-27 17:12:22.000000000 +0800
+++ BBCode.pm 2008-11-29 07:26:56.000000000 +0800
@@ -135,7 +135,7 @@ sub _init {
my %html_tags = (
code => '
Code:
'.
- '%s
',
+ '%s
',
quote => '%s
'.
'%s
',
b => '%s',
@@ -304,7 +304,8 @@ sub _end_tag {
sub _do_BB {
my ($self, @buf) = @_;
- my ($tag, $attr);
+ my ($tag, $attr);
+ my ($codeattr, $codeback, $codecolor); # added by keirachen@zyxel 20081208
my $html;
# Get the opening tag
@@ -314,7 +315,8 @@ sub _do_BB {
# Closing tag is kinda useless, pop it
pop(@buf);
# Rest should be content;
- my $content = join(' ', @buf);
+ #my $content = join(' ', @buf);
+ my $content = join('', @buf); # modified by keirachen@zyxel 20081208 (fix the additional space issue)
# What are we dealing with anyway? Any attributes maybe?
if($open =~ /\[([^=\]]+)=?([^\]]+)?]/) {
@@ -324,7 +326,22 @@ sub _do_BB {
$attr =~ s|<|<|gs;
$attr =~ s|>|>|gs;
}
- }
+ }
+
+ # added by keirachen@zyxel 20081208 (let user can define the color of code block)
+ if($tag eq "code" && $attr ) {
+ $codeattr = "";
+ #$codeback = $attr;
+ if ($attr =~ /[\s\;]?bgcolor:\s*([\#0-9a-zA-Z]+)/ ){
+ $codeback = $1;
+ # $codecolor = $';
+ }
+ if ($attr =~ /^color:\s*([\#0-9a-zA-Z]+)/ || $attr =~ /[\s\;]+color:\s*([\#0-9a-zA-Z]+)/ ){
+ $codecolor = $1;
+ }
+ $codeattr = "background: $codeback; " if ($codeback);
+ $codeattr .= "color: $codecolor; " if ($codecolor);
+ } # end {keirachen}
# Kludgy way to handle specific BBCodes ...
if($tag eq 'quote') {
@@ -334,7 +351,7 @@ sub _do_BB {
$content
);
} elsif($tag eq 'code') {
- $html = sprintf($self->{options}->{html_tags}->{code}, _code($content));
+ $html = sprintf($self->{options}->{html_tags}->{code}, ($codeattr) ? $codeattr : "", _code($content));
} elsif($tag eq 'list') {
$html = _list($self, $attr, $content);
} elsif(($tag eq 'email' || $tag eq 'url') && !$attr) {