repo.or.cz
/
ikiwiki.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
test
[ikiwiki.git]
/
mdwn2man
blob
090174534d48e7cc056a5be13def89db80df6717
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/^\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
}