forked from openresty/openresty-devel-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
twiki2pod.pl
61 lines (47 loc) · 1.12 KB
/
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env perl
use strict;
use warnings;
print "=encoding utf-8\n\n";
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";
} else {
$new_level = 0;
if ($new_level == $level) {
# do nothing
} else {
# $new_level < $level
while ($new_level < $level) {
print "\n\n=back\n\n";
$level--;
}
}
}
s/\[\[([^]]+)\|[^]]+\]\]/$1/g;
s/ ~(\w+)/ $1/g;
s{http://\S+}{L<$&>}g;
s/\{\{\{(.+?)\}\}\}/C<<< $1 >>>/g;
s{//(.*?)//}{I<< $1 >>}g;
print;
}
while ($level > 0) {
print "\n\n=back\n\n";
$level--;
}