summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2009-02-16 22:16:50 +0100
committerYorhel <git@yorhel.nl>2009-02-16 22:18:31 +0100
commit8e9e28370280618ffa11732f1e2f8e64ea379c97 (patch)
treeecc80b98fd8c754f3c918ba210b24cb3a9eff61a /lib
parentcf41784c58cbb8380813dba4d0ea1a56e8478d1f (diff)
Improved handling of excessive newlines and newlines around [quote] tags in VNDB::Func::bb2html()
Diffstat (limited to 'lib')
-rw-r--r--lib/VNDB/Func.pm9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/VNDB/Func.pm b/lib/VNDB/Func.pm
index a472d2e2..8a5c11d4 100644
--- a/lib/VNDB/Func.pm
+++ b/lib/VNDB/Func.pm
@@ -93,6 +93,7 @@ sub bb2html {
my $raw = shift;
my $maxlength = shift;
$raw =~ s/\r//g;
+ $raw =~ s/\n{5,}/\n\n/g;
return '' if !$raw && $raw ne "0";
my($result, $length, $rmnewline, @open) = ('', 0, 0, 'first');
@@ -111,8 +112,8 @@ sub bb2html {
next if !defined $_;
next if $_ eq '';
- $rmnewline = s/\n//g if $rmnewline;
- next if $_ eq '';
+ # (note to self: stop using unreadable hacks like these!)
+ $rmnewline-- && $_ eq "\n" && next if $rmnewline;
my $lit = $_;
if($open[$#open] ne 'raw') {
@@ -121,7 +122,7 @@ sub bb2html {
elsif (lc$_ eq '[quote]') {
push @open, 'quote';
$result .= '<div class="quote">' if !$maxlength;
- $rmnewline++;
+ $rmnewline = 1;
next
} elsif (lc$_ eq '[/spoiler]') {
if($open[$#open] eq 'spoiler') {
@@ -132,7 +133,7 @@ sub bb2html {
} elsif (lc$_ eq '[/quote]') {
if($open[$#open] eq 'quote') {
$result .= '</div>' if !$maxlength;
- $rmnewline++;
+ $rmnewline = 1;
pop @open;
}
next;