line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Trac::Ol; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
55
|
use strict; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
247
|
|
4
|
8
|
|
|
8
|
|
40
|
use warnings; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
220
|
|
5
|
8
|
|
|
8
|
|
39
|
use base qw(Text::Trac::BlockNode); |
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
44
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.22'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub init { |
10
|
120
|
|
|
120
|
0
|
226
|
my $self = shift; |
11
|
120
|
|
|
|
|
2444
|
$self->pattern(qr/(\s+) ([\daiAI])\. \s+ (.*)$/xms); |
12
|
120
|
|
|
|
|
844
|
return $self; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub parse { |
16
|
80
|
|
|
80
|
0
|
152
|
my ( $self, $l ) = @_; |
17
|
80
|
|
|
|
|
129
|
my $c = $self->{context}; |
18
|
80
|
|
|
|
|
1383
|
my $pattern = $self->pattern; |
19
|
80
|
100
|
|
|
|
623
|
$l =~ $pattern or return $l; |
20
|
45
|
|
|
|
|
107
|
my $type = $2; |
21
|
|
|
|
|
|
|
|
22
|
45
|
|
|
|
|
87
|
my $space = length($1); |
23
|
45
|
|
100
|
|
|
785
|
my $level = $c->ol->{level} || 0; |
24
|
45
|
|
100
|
|
|
929
|
$c->ol->{space} ||= 0; |
25
|
|
|
|
|
|
|
|
26
|
45
|
|
|
|
|
248
|
my $start_tag; |
27
|
45
|
100
|
|
|
|
153
|
if ( $type =~ /(\d)/ ) { |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
28
|
10
|
100
|
|
|
|
38
|
$start_tag = $type == 1 ? '' : qq{}; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
elsif ( $type eq 'a' ) { |
31
|
35
|
|
|
|
|
53
|
$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
|
|
|
|
727
|
if ( $space > $c->ol->{space} ) { |
|
|
100
|
|
|
|
|
|
44
|
19
|
|
|
|
|
142
|
for ( 1 .. ( $space + 1 ) / 2 - $level ) { |
45
|
19
|
|
|
|
|
49
|
$l = $start_tag . $l; |
46
|
19
|
|
|
|
|
42
|
$level++; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
elsif ( $space < $c->ol->{space} ) { |
50
|
4
|
|
|
|
|
177
|
for ( 1 .. ( $c->ol->{space} - $space ) / 2 ) { |
51
|
6
|
|
|
|
|
38
|
$l = '' . $l; |
52
|
6
|
|
|
|
|
11
|
$level--; |
53
|
|
|
|
|
|
|
} |
54
|
4
|
|
|
|
|
28
|
$l =~ s!(?<=(?:ol|li)>)(?= )!!; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
else { |
57
|
22
|
|
|
|
|
531
|
$l = "$l"; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
45
|
|
|
|
|
886
|
$c->ol( { level => $level, space => $space } ); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# parse inline nodes |
63
|
45
|
|
|
|
|
543
|
$l =~ s{ $pattern }{'' . $self->replace($3)}xmsge; |
|
45
|
|
|
|
|
170
|
|
64
|
|
|
|
|
|
|
|
65
|
45
|
100
|
100
|
|
|
1809
|
if ( $c->hasnext and $c->nextline =~ $pattern ) { |
66
|
35
|
|
|
|
|
96
|
$self->parse($l); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
else { |
69
|
10
|
|
|
|
|
180
|
for ( 1 .. $c->ol->{level} ) { |
70
|
13
|
|
|
|
|
107
|
$l .= ''; |
71
|
|
|
|
|
|
|
} |
72
|
10
|
|
|
|
|
178
|
$c->ol->{level} = 0; |
73
|
10
|
|
|
|
|
191
|
$c->ol->{space} = 0; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
45
|
|
|
|
|
169
|
$c->htmllines($l); |
77
|
|
|
|
|
|
|
|
78
|
45
|
|
|
|
|
197
|
return; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |