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