You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mdwn2man 608B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/perl
  2. # Warning: hack
  3. my $prog=shift;
  4. my $section=shift;
  5. print ".TH $prog $section\n";
  6. while (<>) {
  7. s{(\\?)\[\[([^\s\|\]]+)(\|[^\s\]]+)?\]\]}{$1 ? "[[$2]]" : $2}eg;
  8. s/\`//g;
  9. s/^\s*\./\\&./g;
  10. if (/^#\s/) {
  11. s/^#\s/.SH /;
  12. <>; # blank;
  13. }
  14. s/^[ \n]+//;
  15. s/^\t/ /;
  16. s/-/\\-/g;
  17. s/^Warning:.*//g;
  18. s/^$/.PP\n/;
  19. s/^\*\s+(.*)/.IP "$1"/;
  20. next if $_ eq ".PP\n" && $skippara;
  21. if (/^.IP /) {
  22. $inlist=1;
  23. $spippara=0;
  24. }
  25. elsif (/.SH/) {
  26. $skippara=0;
  27. $inlist=0;
  28. }
  29. elsif (/^\./) {
  30. $skippara=1;
  31. }
  32. else {
  33. $skippara=0;
  34. }
  35. if ($inlist && $_ eq ".PP\n") {
  36. $_=".IP\n";
  37. }
  38. print $_;
  39. }