forked from openresty/openresty-devel-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
twiki2pod.pl
44 lines (34 loc) · 807 Bytes
/
twiki2pod.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env perl
use strict;
use warnings;
my $level = 0;
while (<>) {
my $new_level;
if (s/^(\*{1,})\s+//) {
$new_level = length $1;
if ($new_level > $level) {
while ($new_level > $level) {
print "\n\n=over\n\n";
$level++;
}
} elsif ($new_level == $level) {
# do nothing
} else {
# $new_level < $level
while ($new_level < $level) {
print "\n\n=back\n\n";
$level--;
}
}
print "\n\n=item *\n\n";
}
s/\[\[([^]]+)\|[^]]+\]\]/$1/g;
s/ ~(\w+)/ $1/g;
s{http://\S+}{L<$&>}g;
s/\{\{\{([^}]+)\}\}\}/C<<< $1 >>>/g;
print;
}
while ($level > 0) {
print "\n\n=back\n\n";
$level--;
}