line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Trac::Ul; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
57
|
use strict; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
267
|
|
4
|
8
|
|
|
8
|
|
41
|
use warnings; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
226
|
|
5
|
8
|
|
|
8
|
|
40
|
use base qw(Text::Trac::BlockNode); |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
49
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.23'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub init { |
10
|
120
|
|
|
120
|
0
|
233
|
my $self = shift; |
11
|
120
|
|
|
|
|
2383
|
$self->pattern(qr/(\s+) \* \s+ (.*)$/xms); |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub parse { |
15
|
77
|
|
|
77
|
0
|
153
|
my ( $self, $l ) = @_; |
16
|
77
|
|
|
|
|
122
|
my $c = $self->{context}; |
17
|
77
|
|
|
|
|
1294
|
my $pattern = $self->pattern; |
18
|
77
|
100
|
|
|
|
547
|
$l =~ $pattern or return $l; |
19
|
|
|
|
|
|
|
|
20
|
43
|
|
|
|
|
102
|
my $space = length($1); |
21
|
43
|
|
100
|
|
|
733
|
my $level = $c->ul->{level} || 0; |
22
|
43
|
|
100
|
|
|
924
|
$c->ul->{space} ||= 0; |
23
|
|
|
|
|
|
|
|
24
|
43
|
100
|
|
|
|
875
|
if ( $space > $c->ul->{space} ) { |
|
|
100
|
|
|
|
|
|
25
|
18
|
|
|
|
|
164
|
for ( 1 .. ( $space + 1 ) / 2 - $level ) { |
26
|
18
|
|
|
|
|
49
|
$l = ' |
27
|
18
|
|
|
|
|
45
|
$level++; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
elsif ( $space < $c->ul->{space} ) { |
31
|
4
|
|
|
|
|
146
|
for ( 1 .. ( $c->ul->{space} - $space ) / 2 ) { |
32
|
6
|
|
|
|
|
42
|
$l = '' . $l; |
33
|
6
|
|
|
|
|
15
|
$level--; |
34
|
|
|
|
|
|
|
} |
35
|
4
|
|
|
|
|
27
|
$l =~ s!(?<=(?:ul|li)>)(?= )!!; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
else { |
38
|
21
|
|
|
|
|
509
|
$l = "$l"; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
43
|
|
|
|
|
827
|
$c->ul( { level => $level, space => $space } ); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# parse inline nodes |
44
|
43
|
|
|
|
|
564
|
$l =~ s{ $pattern }{"" . $self->replace($2)}xmsge; |
|
43
|
|
|
|
|
146
|
|
45
|
|
|
|
|
|
|
|
46
|
43
|
100
|
100
|
|
|
1915
|
if ( $c->hasnext and $c->nextline =~ /$pattern/ ) { |
47
|
34
|
|
|
|
|
97
|
$self->parse($l); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
else { |
50
|
9
|
|
|
|
|
158
|
for ( 1 .. $c->ul->{level} ) { |
51
|
12
|
|
|
|
|
74
|
$l .= ''; |
52
|
|
|
|
|
|
|
} |
53
|
9
|
|
|
|
|
156
|
$c->ul->{level} = 0; |
54
|
9
|
|
|
|
|
177
|
$c->ul->{space} = 0; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# parse inline nodes |
58
|
43
|
|
|
|
|
164
|
$c->htmllines($l); |
59
|
|
|
|
|
|
|
|
60
|
43
|
|
|
|
|
182
|
return; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |