summaryrefslogtreecommitdiff
path: root/mdwn2man
blob: ad6d3c6026400660e87b67367133ce2e4a78fb81 (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/^\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. }