projects
/
ikiwiki
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
blame
|
history
|
raw
|
HEAD
avoid keeping running if a DOS attack is possible
[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\|\]]+)(\|[^\s\]]+)?\]\]}{$1 ? "[[$2]]" : $2}eg;
11
s/\`//g;
12
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
}
40
41
print $_;
42
}