diff options
author | SpaceRanger <space.ranger.vn@gmail.com> | 2012-07-16 15:11:01 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2012-07-16 15:13:53 +0200 |
commit | 9a83733079e17f46c66d761a098952d0f50d93fa (patch) | |
tree | 6ff1f83e921fe8eb8d635f04cb5be4ab2d02ced4 /lib/VNDBUtil.pm | |
parent | e649964b5b74bf1bdc44be9591cff45119aa3096 (diff) |
VNDBUtil::bb2html(): Added support for dx.x.x links
Original patch of SpaceRanger @ http://p.blicky.net/34qcy
I took the liberty of making minor changes to limit the longid match to
dx.x.x and to compact the code a bit.
Diffstat (limited to 'lib/VNDBUtil.pm')
-rw-r--r-- | lib/VNDBUtil.pm | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/VNDBUtil.pm b/lib/VNDBUtil.pm index 7aa75bae..e9df0a2c 100644 --- a/lib/VNDBUtil.pm +++ b/lib/VNDBUtil.pm @@ -54,12 +54,13 @@ sub bb2html { }; while($raw =~ m{( - ([tdvprc][1-9][0-9]*\.[1-9][0-9]*) | # 2. exid - ([tdvprcugi][1-9][0-9]*) | # 3. id - (\[[^\s\]]+\]) | # 4. tag - ((?:https?|ftp)://[^><"\n\s\]\[]+[\d\w=/-]) # 5. url + (d[1-9][0-9]*\.[1-9][0-9]*\.[1-9][0-9]*) | # 2. longid + ([tdvprc][1-9][0-9]*\.[1-9][0-9]*) | # 3. exid + ([tdvprcugi][1-9][0-9]*) | # 4. id + (\[[^\s\]]+\]) | # 5. tag + ((?:https?|ftp)://[^><"\n\s\]\[]+[\d\w=/-]) # 6. url )}xg) { - my($match, $exid, $id, $tag, $url) = ($1, $2, $3, $4, $5); + my($match, $longid, $exid, $id, $tag, $url) = ($1, $2, $3, $4, $5, $6); # add string before the match $result .= $e->(substr $raw, $last, (pos($raw)-length($match))-$last); @@ -114,10 +115,11 @@ sub bb2html { next; } # id - if(($id || $exid) && (!$result || substr($raw, $last-1-length($match), 1) !~ /[\w]/) && substr($raw, $last, 1) !~ /[\w]/) { - $length += length $match; + if(($id || $exid || $longid) && (!$result || substr($raw, $last-1-length($match), 1) !~ /[\w]/) && substr($raw, $last, 1) !~ /[\w]/) { + (my $lnk = $match) =~ s/^d(\d+)\.(\d+)\.(\d+)$/d$1#$2.$3/; + $length += length $lnk; last if $maxlength && $length > $maxlength; - $result .= sprintf '<a href="/%s">%1$s</a>', $match; + $result .= sprintf '<a href="/%s">%s</a>', $lnk, $match; next } } |