--- trunk/back2html.pm 2003/07/04 21:35:34 65
+++ trunk/back2html.pm 2003/11/16 22:39:36 151
@@ -7,15 +7,30 @@
sub back2html {
my $html = shift;
+ $html =~ s/</g;
+ $html =~ s/>/>/g;
my $out;
- foreach $line (split(/###/,$html)) {
- $out .= "
";
- my @items = split(/#-#/,$line);
- $items[1] =~ s#(.*)\b(http://[\w\./]+)(\b?.*)#$1$2$3#g;
+ foreach $line (split(/\s*###\s*/,$html)) {
+ $out .= " |
";
+ my @items = split(/\s*#-#\s*/,$line);
+ # convert spaces in left field to non-breaking spaces
+ $items[0] =~ s#\s+# #g;
+ # try to make link on right field
+ sub mkurl {
+ my $url = shift || die "mkurl needs url as argument";
+ # chop URLS longer than 60 characters
+ my $txturl = substr($1,0,60);
+ $txturl .= "..." if (length($1) > 60);
+ return "$txturl";
+ }
+ $items[1] =~ s#(http://[\S]+)#mkurl($1)#gie;
$out .= join(" | ",@items);
$out .= " |
\n";
}
- $out =~ s/<br\/*>/
/g;
+ # put
back into html
+ $out =~ s,<br/*>,
,gi;
+ # put yyyy back into html
+ $out =~ s,<(a\s+href=)(.+?)>(.+?)<(/a)>,<$1$2>$3<$4>,gsi;
return $out;
}