summaryrefslogtreecommitdiff
path: root/lib/VNDBUtil.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2010-11-27 09:32:01 +0100
committerYorhel <git@yorhel.nl>2010-11-27 09:32:01 +0100
commitfabd5720d5157754406ea5b69e900db632ed035e (patch)
tree55267ad2008d01c22c8765fd1b8754af111a008d /lib/VNDBUtil.pm
parent5a74f0fe0564807657ced8e9773075c2391c5cce (diff)
VNDBUtil: Fixed minor bug in bb2html() and small cleanup
Unknown/incorrect tags should be outputted as-is, as was the case with the previous implementation. Also cleaned up the id and exid if statement to be slightly shorter.
Diffstat (limited to 'lib/VNDBUtil.pm')
-rw-r--r--lib/VNDBUtil.pm26
1 files changed, 15 insertions, 11 deletions
diff --git a/lib/VNDBUtil.pm b/lib/VNDBUtil.pm
index 82363bcf..b0213d07 100644
--- a/lib/VNDBUtil.pm
+++ b/lib/VNDBUtil.pm
@@ -71,32 +71,39 @@ sub bb2html {
if($tag) {
$tag = lc $tag;
if($tag eq '[raw]') {
- push @open, 'raw'
+ push @open, 'raw';
+ next;
} elsif($tag eq '[spoiler]') {
push @open, 'spoiler';
- $result .= '<b class="spoiler">'
+ $result .= '<b class="spoiler">';
+ next;
} elsif($tag eq '[quote]') {
push @open, 'quote';
$result .= '<div class="quote">' if !$maxlength;
$rmnewline = 1;
+ next;
} elsif($tag eq '[code]') {
push @open, 'code';
$result .= '<pre>' if !$maxlength;
$rmnewline = 1;
+ next;
} elsif($tag eq '[/spoiler]' && $open[$#open] eq 'spoiler') {
$result .= '</b>';
pop @open;
+ next;
} elsif($tag eq '[/quote]' && $open[$#open] eq 'quote') {
$result .= '</div>' if !$maxlength;
$rmnewline = 1;
+ next;
} elsif($tag eq '[/url]' && $open[$#open] eq 'url') {
$result .= '</a>';
pop @open;
+ next;
} elsif($tag =~ s{\[url=((https?://|/)[^\]>]+)\]}{<a href="$1" rel="nofollow">}i) {
$result .= $tag;
push @open, 'url';
+ next;
}
- next;
}
# handle URLs
if($url && !grep(/url/, @open)) {
@@ -106,14 +113,11 @@ sub bb2html {
next;
}
# id
- if($id || $exid) {
- my $r = $id || $exid;
- if(substr($raw, $last-1-length($r), 1) !~ /[\w]/ && substr($raw, $last, 1) !~ /[\w]/) {
- $length += length $r;
- last if $maxlength && $length > $maxlength;
- $result .= sprintf '<a href="/%s">%1$s</a>', $r;
- next
- }
+ if(($id || $exid) && substr($raw, $last-1-length($match), 1) !~ /[\w]/ && substr($raw, $last, 1) !~ /[\w]/) {
+ $length += length $match;
+ last if $maxlength && $length > $maxlength;
+ $result .= sprintf '<a href="/%s">%1$s</a>', $match;
+ next
}
}