X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=back2html.pm;h=860a1d68d4e2efd02bc9da11fc7b06d50aa1390f;hb=f23c2077101da75ff16dc377aebc01819e40d4c9;hp=915c711ddb38a57e73d66d593b95b4370d96c3d8;hpb=a936479795a193ed3e98b8843d132af510038e41;p=webpac diff --git a/back2html.pm b/back2html.pm index 915c711..860a1d6 100644 --- a/back2html.pm +++ b/back2html.pm @@ -7,17 +7,30 @@ sub back2html { my $html = shift; + $html =~ s//>/g; my $out; - foreach $line (split(/###/,$html)) { - $out .= ""; - my @items = split(/#-#/,$line); - if ($items[1] =~ m#^http://#) { - $items[1] = "$items[1]"; + 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; }