]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - mdwn2man
web commit by http://xayk.net/
[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         if (/^#\s/) {
12                 s/^#\s/.SH /;
13                 <>; # blank;
14         }
15         s/^\s+//;
16         s/-/\\-/g;
17         s/^Warning:.*//g;
18         s/^$/.PP\n/;
19         s/\`//g;
20         s/^\*\s+(.*)/.IP "$1"/;
21         next if $_ eq ".PP\n" && $skippara;
22         if (/^.IP /) {
23                 $inlist=1;
24                 $spippara=0;
25         }
26         elsif (/.SH/) {
27                 $skippara=0;
28                 $inlist=0;
29         }
30         elsif (/^\./) {
31                 $skippara=1;
32         }
33         else {
34                 $skippara=0;
35         }
36         if ($inlist && $_ eq ".PP\n") {
37                 $_=".IP\n";
38         }
40         print $_;
41 }