1 |
# |
2 |
# reformat html inside xml back to html (basically, support for tables) |
3 |
# |
4 |
# filed #-# field ### |
5 |
# ... |
6 |
|
7 |
sub back2html { |
8 |
my $html = shift; |
9 |
|
10 |
my $out; |
11 |
foreach $line (split(/###/,$html)) { |
12 |
$out .= "<tr><td>"; |
13 |
my @items = split(/#-#/,$line); |
14 |
if ($items[1] =~ m#(http://[\S]+)\s*.*?#i) { |
15 |
# chop URLS longer than 60 characters |
16 |
my $url = substr($1,0,60); |
17 |
$url .= "..." if (length($1) > 60); |
18 |
$items[1] =~ s#(.*)\b(http://[\S]+)(\b?.*)#$1<a href=\"$2\">$url</a>$3#g; |
19 |
} |
20 |
$out .= join("</td><td>",@items); |
21 |
$out .= "</td></tr>\n"; |
22 |
} |
23 |
$out =~ s/<br\/*>/<br\/>/g; |
24 |
return $out; |
25 |
} |
26 |
|
27 |
1; |