plan9port/dist/addsrclinks

25 lines
484 B
Text
Raw Normal View History

2005-02-15 05:07:26 +00:00
#!/usr/bin/perl
@_ = <>;
my $root = $ENV{'PLAN9'};
my $html = join("", @_);
2005-03-18 18:53:21 +00:00
$html =~ s;$root/;XXX$root/;g;
2005-02-15 05:07:26 +00:00
while($html =~ /((.|\n)*)XXX($root\/([a-zA-Z0-9_.\/]|&#8722;)*[a-zA-Z0-9_\/])((.|\n)*)/){
($a, $b, $c) = ($1, $3, $5);
$b =~ s/&#8722;/-/g;
$l = $b;
while(! -e $l){
if($l =~ /(.*\/)(.+)/){
$l = $1;
}else{
last;
}
}
$bb = substr($b, length($l));
$b = $l;
$b =~ s/-/\&#8722;/g;
$bb =~ s/-/\&#8722;/g;
$html = "$a<a href=\"$l\">$b</a>$bb$c";
}
print $html;