fixurls (787B)
1 #!/usr/bin/perl 2 3 open(OMIT, "9 sed -n 's/.*Omitman\\[\"(.*)\\((.)\\)\".*/\\1 \\2/p' /usr/local/plan9/dist/checkman.awk |") || die "omit: $!"; 4 @omit = <OMIT>; 5 close OMIT; 6 chomp @omit; 7 push @omit, "grep 1", "lseek 2", "tcs 1", "sed 1", "rc 1", "strcat 3", "yacc 1"; 8 9 sub noref { 10 my ($p, $s) = @_; 11 12 $text =~ s!<a href="../man$s/$p.html">(([^<]|<[^/]|</[^a])*)</a>!\1!g; 13 } 14 15 for($i=0; $i<@ARGV; $i++){ 16 open(IN, $ARGV[$i]) || die "open $ARGV[$i]: $!"; 17 @text = <IN>; 18 close IN; 19 $text = join("", @text); 20 21 foreach $o (@omit) { 22 $o =~ /(.*) (.*)/; 23 noref($1, $2); 24 } 25 26 $text =~ s!../man(.)/([^.]*)\.html!$2$1.html!g; 27 $text =~ s!(https://9fans.github.io/plan9port/unix)!<a href="\1">\1</a>!g; 28 29 open(OUT, ">$ARGV[$i]") || die "open $ARGV[$i]: $!"; 30 print OUT $text; 31 close OUT; 32 } 33 34 exit 0;