add source links
This commit is contained in:
parent
0c891f28db
commit
7383736cf8
5 changed files with 34 additions and 7 deletions
24
dist/addsrclinks
vendored
Executable file
24
dist/addsrclinks
vendored
Executable file
|
|
@ -0,0 +1,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;
|
||||
Loading…
Add table
Add a link
Reference in a new issue