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