projects
/
ikiwiki
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
blame
|
history
|
raw
|
HEAD
web commit by RecaiOktas
[ikiwiki]
/
mdwn2man
1
#!/usr/bin/perl
2
# Warning: hack
3
4
my $prog=shift;
5
my $section=shift;
6
7
print ".TH $prog $section\n";
8
9
while (<>) {
10
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
}
39
40
print $_;
41
}