blob: 9f87b8a1910cadd176f3b8412105e5f77d61d057 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#!/usr/bin/perl
@_ = <>;
my $root = $ENV{'PLAN9'};
my $html = join("", @_);
$html =~ s;$root/;XXX$root/;g;
while($html =~ /((.|\n)*)XXX($root\/([a-zA-Z0-9_.\/]|−)*[a-zA-Z0-9_\/])((.|\n)*)/){
($a, $b, $c) = ($1, $3, $5);
$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;
$html = "$a<a href=\"$l\">$b</a>$bb$c";
}
print $html;
|