2
0

mkpod2html.pl 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #! /usr/bin/env perl
  2. # Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.
  3. #
  4. # Licensed under the Apache License 2.0 (the "License"). You may not use
  5. # this file except in compliance with the License. You can obtain a copy
  6. # in the file LICENSE in the source distribution or at
  7. # https://www.openssl.org/source/license.html
  8. use strict;
  9. use warnings;
  10. use lib ".";
  11. use Getopt::Std;
  12. use Pod::Html;
  13. # Options.
  14. our($opt_i); # -i INFILE
  15. our($opt_o); # -o OUTFILE
  16. our($opt_t); # -t TITLE
  17. our($opt_r); # -r PODROOT
  18. getopts('i:o:t:r:');
  19. die "-i flag missing" unless $opt_i;
  20. die "-o flag missing" unless $opt_o;
  21. die "-t flag missing" unless $opt_t;
  22. die "-r flag missing" unless $opt_r;
  23. pod2html
  24. "--infile=$opt_i",
  25. "--outfile=$opt_o",
  26. "--title=$opt_t",
  27. "--podroot=$opt_r",
  28. "--podpath=man1:man3:man5:man7",
  29. "--htmldir=..";
  30. # Read in contents.
  31. open F, "<$opt_o"
  32. or die "Can't read $opt_o, $!";
  33. my $contents = '';
  34. {
  35. local $/ = undef;
  36. $contents = <F>;
  37. }
  38. close F;
  39. unlink $opt_o;
  40. $contents =~
  41. s|href="http://man\.he\.net/(man\d/[^"]+)(?:\.html)?"|href="../$1.html"|g;
  42. open F, ">$opt_o"
  43. or die "Can't write $opt_o, $!";
  44. print F $contents;
  45. close F;