From 8e9e28370280618ffa11732f1e2f8e64ea379c97 Mon Sep 17 00:00:00 2001 From: Yorhel Date: Mon, 16 Feb 2009 22:16:50 +0100 Subject: Improved handling of excessive newlines and newlines around [quote] tags in VNDB::Func::bb2html() --- lib/VNDB/Func.pm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/VNDB/Func.pm') 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 .= '
' 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 .= '
' if !$maxlength; - $rmnewline++; + $rmnewline = 1; pop @open; } next; -- cgit v1.2.3