diff options
author | Yorhel <git@yorhel.nl> | 2008-12-29 12:26:25 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2008-12-29 12:26:25 +0100 |
commit | ed73cef37914303ca1790a37c6f5bec13b326b1f (patch) | |
tree | 01b121267ef56763361df3d4461563c929e60da2 /lib/VNDB | |
parent | 412b3bb8baeef93869c92687956a007841d4492c (diff) |
Added [quote] tag formatting, fixed URL parser, and updated d9
Diffstat (limited to 'lib/VNDB')
-rw-r--r-- | lib/VNDB/Func.pm | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/lib/VNDB/Func.pm b/lib/VNDB/Func.pm index 1833be37..330dad7d 100644 --- a/lib/VNDB/Func.pm +++ b/lib/VNDB/Func.pm @@ -86,6 +86,7 @@ sub userstr { # [url=..] [/url] # [raw] .. [/raw] # [spoiler] .. [/spoiler] +# [quote] .. [/quote] # v+, v+.+ # http://../ sub bb2html { @@ -94,7 +95,7 @@ sub bb2html { $raw =~ s/\r//g; return '' if !$raw && $raw ne "0"; - my($result, $length, @open) = ('', 0, 'first'); + my($result, $length, $rmnewline, @open) = ('', 0, 0, 'first'); my $e = sub { local $_ = shift; @@ -108,17 +109,33 @@ sub bb2html { for (split /(\s|\n|\[[^\]]+\])/, $raw) { next if !defined $_; + next if $_ eq ''; + + $rmnewline = s/\n//g if $rmnewline; + next if $_ eq ''; my $lit = $_; if($open[$#open] ne 'raw') { if ($_ eq '[raw]') { push @open, 'raw'; next } elsif ($_ eq '[spoiler]') { push @open, 'spoiler'; $result .= '<b class="spoiler">'; next } - elsif ($_ eq '[/spoiler]') { + elsif ($_ eq '[quote]') { + push @open, 'quote'; + $result .= '<div class="quote">' if !$maxlength; + $rmnewline++; + next + } elsif ($_ eq '[/spoiler]') { if($open[$#open] eq 'spoiler') { $result .= '</b>'; pop @open; } next; + } elsif ($_ eq '[/quote]') { + if($open[$#open] eq 'quote') { + $result .= '</div>' if !$maxlength; + $rmnewline++; + pop @open; + } + next; } elsif($_ eq '[/url]') { if($open[$#open] eq 'url') { $result .= '</a>'; @@ -130,7 +147,7 @@ sub bb2html { push @open, 'url'; next; } elsif(!grep(/url/, @open) && - s{(.*)(http|https)://(.+[0-9a-zA-Z=/])(.*)} + s{(.*)(http|https)://(.+[\d\w=/-])(.*)} {$e->($1).qq|<a href="$2://|.$e->($3, 1).'" rel="nofollow">'.$e->('link').'</a>'.$e->($4)}e) { $length += 4; last if $maxlength && $length > $maxlength; @@ -155,7 +172,7 @@ sub bb2html { $result .= $e->($_); } - $result .= '</a>' + $result .= $_ eq 'url' ? '</a>' : $_ eq 'quote' ? '</div>' : '</b>' while((local $_ = pop @open) ne 'first'); $result .= '...' if $maxlength && $length > $maxlength; |