/[webpac]/trunk/back2html.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/back2html.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 146 - (hide annotations)
Sun Nov 16 13:20:14 2003 UTC (16 years ago) by dpavlin
File size: 839 byte(s)
convert more than one URL to correct html link

1 dpavlin 13 #
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 dpavlin 80 $html =~ s/</&lt;/g;
11     $html =~ s/>/&gt;/g;
12 dpavlin 13 my $out;
13 dpavlin 79 foreach $line (split(/\s*###\s*/,$html)) {
14     $out .= "<tr><td valign=\"top\">";
15     my @items = split(/\s*#-#\s*/,$line);
16     # convert spaces in left field to non-breaking spaces
17     $items[0] =~ s#\s+#&nbsp;#g;
18     # try to make link on right field
19 dpavlin 146 sub mkurl {
20     my $url = shift || die "mkurl needs url as argument";
21 dpavlin 66 # chop URLS longer than 60 characters
22 dpavlin 146 my $txturl = substr($1,0,60);
23     $txturl .= "..." if (length($1) > 60);
24     return "<a href=\"$url\">$txturl</a>";
25 dpavlin 66 }
26 dpavlin 146 $items[1] =~ s#(http://[\S]+)#mkurl($1)#gie;
27 dpavlin 13 $out .= join("</td><td>",@items);
28     $out .= "</td></tr>\n";
29     }
30 dpavlin 31 $out =~ s/&lt;br\/*&gt;/<br\/>/g;
31 dpavlin 13 return $out;
32     }
33    
34     1;

Properties

Name Value
cvs2svn:cvs-rev 1.10

  ViewVC Help
Powered by ViewVC 1.1.26