taddsrclinks - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
       taddsrclinks (522B)
       ---
            1 #!/usr/bin/env perl
            2 
            3 @_ = <>;
            4 my $root = $ENV{'PLAN9'};
            5 my $html = join("", @_);
            6 $html =~ s;$root/;XXX$root/;g;
            7 $newhtml = "";
            8 while($html =~ /XXX($root\/([a-zA-Z0-9_.\/]|&#8722;)*[a-zA-Z0-9_\/])/){
            9         ($a, $b, $c) = ($`, $1, $');
           10         $b =~ s/&#8722;/-/g;
           11         $l = $b;
           12         while(! -e $l){
           13                 if($l =~ /(.*\/)(.+)/){
           14                         $l = $1;
           15                 }else{
           16                         last;
           17                 }
           18         }
           19         $bb = substr($b, length($l));
           20         $b = $l;
           21         $b =~ s/-/\&#8722;/g;
           22         $bb =~ s/-/\&#8722;/g;
           23         $newhtml .= "$a<a href=\"$l\">$b</a>$bb";
           24         $html = $c;
           25 }
           26 $newhtml .= $html;
           27 print $newhtml;