]> i-scream Git - www.i-scream.org.git/commitdiff
URL's are actually linked now... which is nice :-)
authorTim Bishop <tim@bishnet.net>
Thu, 9 Nov 2000 22:03:56 +0000 (22:03 +0000)
committerTim Bishop <tim@bishnet.net>
Thu, 9 Nov 2000 22:03:56 +0000 (22:03 +0000)
cgi-bin/docs.cgi

index 6760915f660057df6c621761aa92c3e39f764961..cb6c3d2bbe8dbb9fa83e81024156f0a96e7b5586 100755 (executable)
@@ -77,6 +77,20 @@ exit 0;
 
 # Print a file, whilst escaping HTML: -
 sub print_file ($) {
+    my ($urls) = '(' . join ('|', qw{
+                       http
+                       telnet
+                       gopher
+                       file
+                       wais
+                       ftp
+                       } )
+                   . ')';
+    
+    my ($ltrs) = '\w';
+    my ($gunk) = '/#~:.?+=&%@!\-';
+    my ($punc) = '.:?\-';
+    my ($any) = "${ltrs}${gunk}${punc}";
     my ($filename) = @_;
     open(FILE, $filename) or die "Cannot open $filename: $!\n";
     print "<pre>\n";
@@ -87,6 +101,7 @@ sub print_file ($) {
         s/</&lt;/g;
         s/>/&gt;/g;
         s/"/&quot;/g;
+        s/\b($urls:[$any]+?)(?=[$punc]*[^$any]|$)/<a href="$1">$1<\/a>/igox;
         print;
     }
     print "</pre>";