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
minor fix-ups
[ikiwiki.git]
/
mdwn2man
blob
ad6d3c6026400660e87b67367133ce2e4a78fb81
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/^[ \n]+//
;
18
s/^\t/ /
;
19
s/-/\\-/g
;
20
s/^Warning:.*//g
;
21
s/^$/.PP\n/
;
22
s/^\*\s+(.*)/.IP "$1"/
;
23
next if
$_
eq
".PP
\n
"
&&
$skippara
;
24
if
(
/^.IP /
) {
25
$inlist
=
1
;
26
$spippara
=
0
;
27
}
28
elsif
(
/.SH/
) {
29
$skippara
=
0
;
30
$inlist
=
0
;
31
}
32
elsif
(
/^\./
) {
33
$skippara
=
1
;
34
}
35
else
{
36
$skippara
=
0
;
37
}
38
if
(
$inlist
&&
$_
eq
".PP
\n
"
) {
39
$_
=
".IP
\n
"
;
40
}
41
42
print
$_
;
43
}