diff options
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | data/docs/9 | 4 | ||||
-rw-r--r-- | lib/VNDB/Func.pm | 23 |
3 files changed, 23 insertions, 5 deletions
@@ -3,6 +3,7 @@ git - ? - Implemented proper daemonizing and error handling for Multi - Added basic Makefile - Added public database API + - Added [code] tag to bb2html() 2.8 - 2009-10-24 - Converted relation graphs to use inline SVG diff --git a/data/docs/9 b/data/docs/9 index f5ee46ab..fedbd2b0 100644 --- a/data/docs/9 +++ b/data/docs/9 @@ -62,6 +62,10 @@ </dd><dt>[raw]</dt><dd> Show off your formatting code skills by putting anything you don't want to have formatted in a [raw] tag. Any of the formatting codes mentioned above are ignored within a [raw] .. [/raw] block. + </dd><dt>[code]</dt><dd> + Similar to [raw], except that the text within the [code] .. [/code] block is + formatted in a fixed width font and surrounded by a nice box to keep it + separate from the rest of your post. </dd> </dl> <p> diff --git a/lib/VNDB/Func.pm b/lib/VNDB/Func.pm index ad38215e..49df0121 100644 --- a/lib/VNDB/Func.pm +++ b/lib/VNDB/Func.pm @@ -22,6 +22,7 @@ sub shorten { # [raw] .. [/raw] # [spoiler] .. [/spoiler] # [quote] .. [/quote] +# [code] .. [/code] # v+, v+.+ # http://../ sub bb2html { @@ -51,7 +52,7 @@ sub bb2html { $rmnewline-- && $_ eq "\n" && next if $rmnewline; my $lit = $_; - if($open[$#open] ne 'raw') { + if($open[$#open] ne 'raw' && $open[$#open] ne 'code') { if (lc$_ eq '[raw]') { push @open, 'raw'; next } elsif (lc$_ eq '[spoiler]') { push @open, 'spoiler'; $result .= '<b class="spoiler">'; next } elsif (lc$_ eq '[quote]') { @@ -59,6 +60,11 @@ sub bb2html { $result .= '<div class="quote">' if !$maxlength; $rmnewline = 1; next + } elsif (lc$_ eq '[code]') { + push @open, 'code'; + $result .= '<pre>' if !$maxlength; + $rmnewline = 1; + next } elsif (lc$_ eq '[/spoiler]') { if($open[$#open] eq 'spoiler') { $result .= '</b>'; @@ -97,8 +103,12 @@ sub bb2html { $result .= $_; next; } - } elsif(lc$_ eq '[/raw]') { - pop @open if $open[$#open] eq 'raw'; + } elsif($open[$#open] eq 'raw' && lc$_ eq '[/raw]') { + pop @open; + next; + } elsif($open[$#open] eq 'code' && lc$_ eq '[/code]') { + $result .= '</pre>' if !$maxlength; + pop @open; next; } @@ -108,8 +118,11 @@ sub bb2html { $result .= $e->($_); } - $result .= $_ eq 'url' ? '</a>' : $_ eq 'quote' ? '</div>' : '</b>' - while((local $_ = pop @open) ne 'first'); + # close open tags + while((local $_ = pop @open) ne 'first') { + $result .= $_ eq 'url' ? '</a>' : $_ eq 'spoiler' ? '</b>' : ''; + $result .= $_ eq 'quote' ? '</div>' : $_ eq 'code' ? '</pre>' : '' if !$maxlength; + } $result .= '...' if $maxlength && $length > $maxlength; return $result; |