line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Trac::Ol; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
50
|
use strict; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
206
|
|
4
|
8
|
|
|
8
|
|
35
|
use warnings; |
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
202
|
|
5
|
8
|
|
|
8
|
|
33
|
use base qw(Text::Trac::BlockNode); |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
35
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.24'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub init { |
10
|
120
|
|
|
120
|
0
|
214
|
my $self = shift; |
11
|
120
|
|
|
|
|
2069
|
$self->pattern(qr/(\s+) ([\daiAI])\. \s+ (.*)$/xms); |
12
|
120
|
|
|
|
|
705
|
return $self; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub parse { |
16
|
80
|
|
|
80
|
0
|
135
|
my ( $self, $l ) = @_; |
17
|
80
|
|
|
|
|
114
|
my $c = $self->{context}; |
18
|
80
|
|
|
|
|
1140
|
my $pattern = $self->pattern; |
19
|
80
|
100
|
|
|
|
459
|
$l =~ $pattern or return $l; |
20
|
45
|
|
|
|
|
91
|
my $type = $2; |
21
|
|
|
|
|
|
|
|
22
|
45
|
|
|
|
|
69
|
my $space = length($1); |
23
|
45
|
|
100
|
|
|
632
|
my $level = $c->ol->{level} || 0; |
24
|
45
|
|
100
|
|
|
780
|
$c->ol->{space} ||= 0; |
25
|
|
|
|
|
|
|
|
26
|
45
|
|
|
|
|
205
|
my $start_tag; |
27
|
45
|
100
|
|
|
|
138
|
if ( $type =~ /(\d)/ ) { |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
28
|
10
|
100
|
|
|
|
32
|
$start_tag = $type == 1 ? '' : qq{}; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
elsif ( $type eq 'a' ) { |
31
|
35
|
|
|
|
|
46
|
$start_tag = q{}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
elsif ( $type eq 'A' ) { |
34
|
0
|
|
|
|
|
0
|
$start_tag = q{}; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
elsif ( $type eq 'i' ) { |
37
|
0
|
|
|
|
|
0
|
$start_tag = q{}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
elsif ( $type eq 'I' ) { |
40
|
0
|
|
|
|
|
0
|
$start_tag = q{}; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
45
|
100
|
|
|
|
606
|
if ( $space > $c->ol->{space} ) { |
|
|
100
|
|
|
|
|
|
44
|
19
|
|
|
|
|
131
|
for ( 1 .. ( $space + 1 ) / 2 - $level ) { |
45
|
19
|
|
|
|
|
43
|
$l = $start_tag . $l; |
46
|
19
|
|
|
|
|
38
|
$level++; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
elsif ( $space < $c->ol->{space} ) { |
50
|
4
|
|
|
|
|
121
|
for ( 1 .. ( $c->ol->{space} - $space ) / 2 ) { |
51
|
6
|
|
|
|
|
28
|
$l = '' . $l; |
52
|
6
|
|
|
|
|
11
|
$level--; |
53
|
|
|
|
|
|
|
} |
54
|
4
|
|
|
|
|
25
|
$l =~ s!(?<=(?:ol|li)>)(?= )!!; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
else { |
57
|
22
|
|
|
|
|
460
|
$l = "$l"; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
45
|
|
|
|
|
717
|
$c->ol( { level => $level, space => $space } ); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# parse inline nodes |
63
|
45
|
|
|
|
|
477
|
$l =~ s{ $pattern }{'' . $self->replace($3)}xmsge; |
|
45
|
|
|
|
|
125
|
|
64
|
|
|
|
|
|
|
|
65
|
45
|
100
|
100
|
|
|
1600
|
if ( $c->hasnext and $c->nextline =~ $pattern ) { |
66
|
35
|
|
|
|
|
89
|
$self->parse($l); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
else { |
69
|
10
|
|
|
|
|
151
|
for ( 1 .. $c->ol->{level} ) { |
70
|
13
|
|
|
|
|
66
|
$l .= ''; |
71
|
|
|
|
|
|
|
} |
72
|
10
|
|
|
|
|
142
|
$c->ol->{level} = 0; |
73
|
10
|
|
|
|
|
158
|
$c->ol->{space} = 0; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
45
|
|
|
|
|
138
|
$c->htmllines($l); |
77
|
|
|
|
|
|
|
|
78
|
45
|
|
|
|
|
161
|
return; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |