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