doubtfil about patch #3
[ikiwiki.git] / mdwn2man
blobad6d3c6026400660e87b67367133ce2e4a78fb81
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/^[ \n]+//;
18 s/^\t/ /;
19 s/-/\\-/g;
20 s/^Warning:.*//g;
21 s/^$/.PP\n/;
22 s/^\*\s+(.*)/.IP "$1"/;
23 next if $_ eq ".PP\n" && $skippara;
24 if (/^.IP /) {
25 $inlist=1;
26 $spippara=0;
28 elsif (/.SH/) {
29 $skippara=0;
30 $inlist=0;
32 elsif (/^\./) {
33 $skippara=1;
35 else {
36 $skippara=0;
38 if ($inlist && $_ eq ".PP\n") {
39 $_=".IP\n";
42 print $_;