/[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 337 - (hide annotations)
Thu Jun 10 19:22:40 2004 UTC (15 years, 4 months ago) by dpavlin
File size: 979 byte(s)
new trunk for webpac v2

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 151 # put <br> back into html
31     $out =~ s,&lt;br/*&gt;,<br/>,gi;
32     # put <a href=xxx>yyyy</a> back into html
33     $out =~ s,&lt;(a\s+href=)(.+?)&gt;(.+?)&lt;(/a)&gt;,<$1$2>$3<$4>,gsi;
34 dpavlin 13 return $out;
35     }
36    
37     1;

Properties

Name Value
cvs2svn:cvs-rev 1.11

  ViewVC Help
Powered by ViewVC 1.1.26