/[webpac]/trunk2/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 /trunk2/back2html.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 80 - (hide annotations)
Tue Jul 8 08:24:13 2003 UTC (20 years, 8 months ago) by dpavlin
Original Path: trunk/back2html.pm
File size: 797 byte(s)
fixed bugs with < and > in headline

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 66 if ($items[1] =~ m#(http://[\S]+)\s*.*?#i) {
20     # chop URLS longer than 60 characters
21     my $url = substr($1,0,60);
22     $url .= "..." if (length($1) > 60);
23     $items[1] =~ s#(.*)\b(http://[\S]+)(\b?.*)#$1<a href=\"$2\">$url</a>$3#g;
24     }
25 dpavlin 13 $out .= join("</td><td>",@items);
26     $out .= "</td></tr>\n";
27     }
28 dpavlin 31 $out =~ s/&lt;br\/*&gt;/<br\/>/g;
29 dpavlin 13 return $out;
30     }
31    
32     1;

Properties

Name Value
cvs2svn:cvs-rev 1.9

  ViewVC Help
Powered by ViewVC 1.1.26