web commit by joey
[ikiwiki] / mdwn2man
1 #!/usr/bin/perl
2 # Warning: hack
3
4 print ".TH ikiwiki 1\n";
5
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
33         print $_;
34 }