mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-12 11:10:07 +00:00
27 lines
522 B
Perl
Executable file
27 lines
522 B
Perl
Executable file
#!/usr/bin/env perl
|
|
|
|
@_ = <>;
|
|
my $root = $ENV{'PLAN9'};
|
|
my $html = join("", @_);
|
|
$html =~ s;$root/;XXX$root/;g;
|
|
$newhtml = "";
|
|
while($html =~ /XXX($root\/([a-zA-Z0-9_.\/]|−)*[a-zA-Z0-9_\/])/){
|
|
($a, $b, $c) = ($`, $1, $');
|
|
$b =~ s/−/-/g;
|
|
$l = $b;
|
|
while(! -e $l){
|
|
if($l =~ /(.*\/)(.+)/){
|
|
$l = $1;
|
|
}else{
|
|
last;
|
|
}
|
|
}
|
|
$bb = substr($b, length($l));
|
|
$b = $l;
|
|
$b =~ s/-/\−/g;
|
|
$bb =~ s/-/\−/g;
|
|
$newhtml .= "$a<a href=\"$l\">$b</a>$bb";
|
|
$html = $c;
|
|
}
|
|
$newhtml .= $html;
|
|
print $newhtml;
|