2005-08-10 18:52:00 +00:00
|
|
|
#!/usr/bin/env perl
|
2005-02-15 05:07:26 +00:00
|
|
|
|
|
|
|
@_ = <>;
|
|
|
|
my $root = $ENV{'PLAN9'};
|
|
|
|
my $html = join("", @_);
|
2005-03-18 18:53:21 +00:00
|
|
|
$html =~ s;$root/;XXX$root/;g;
|
2008-07-03 22:50:23 +00:00
|
|
|
$newhtml = "";
|
|
|
|
while($html =~ /XXX($root\/([a-zA-Z0-9_.\/]|−)*[a-zA-Z0-9_\/])/){
|
|
|
|
($a, $b, $c) = ($`, $1, $');
|
2005-02-15 05:07:26 +00:00
|
|
|
$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;
|
2008-07-03 22:50:23 +00:00
|
|
|
$newhtml .= "$a<a href=\"$l\">$b</a>$bb";
|
|
|
|
$html = $c;
|
2005-02-15 05:07:26 +00:00
|
|
|
}
|
2008-07-03 22:50:23 +00:00
|
|
|
$newhtml .= $html;
|
|
|
|
print $newhtml;
|