]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - mdwn2man
Add a fullpage arg to filter.
[git.ikiwiki.info.git] / mdwn2man
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;
16         }
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;
26         }
27         elsif (/.SH/) {
28                 $skippara=0;
29                 $inlist=0;
30         }
31         elsif (/^\./) {
32                 $skippara=1;
33         }
34         else {
35                 $skippara=0;
36         }
37         if ($inlist && $_ eq ".PP\n") {
38                 $_=".IP\n";
39         }
41         print $_;
42 }