summaryrefslogtreecommitdiff
path: root/mdwn2man
blob: d3db4316505f6fa79500d032269b28b39245b7fe (plain)
  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. if (/^#\s/) {
  9. s/^#\s/.SH /;
  10. <>; # blank;
  11. }
  12. s/^\s+//;
  13. s/-/\\-/g;
  14. s/^Warning:.*//g;
  15. s/^$/.PP\n/;
  16. s/\`//g;
  17. s/^\*\s+(.*)/.IP "$1"/;
  18. next if $_ eq ".PP\n" && $skippara;
  19. if (/^.IP /) {
  20. $inlist=1;
  21. $spippara=0;
  22. }
  23. elsif (/.SH/) {
  24. $skippara=0;
  25. $inlist=0;
  26. }
  27. elsif (/^\./) {
  28. $skippara=1;
  29. }
  30. else {
  31. $skippara=0;
  32. }
  33. if ($inlist && $_ eq ".PP\n") {
  34. $_=".IP\n";
  35. }
  36. print $_;
  37. }