line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Trac::Ul; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
47
|
use strict; |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
218
|
|
4
|
8
|
|
|
8
|
|
33
|
use warnings; |
|
8
|
|
|
|
|
40
|
|
|
8
|
|
|
|
|
191
|
|
5
|
8
|
|
|
8
|
|
35
|
use base qw(Text::Trac::BlockNode); |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
37
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.24'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub init { |
10
|
120
|
|
|
120
|
0
|
208
|
my $self = shift; |
11
|
120
|
|
|
|
|
2020
|
$self->pattern(qr/(\s+) \* \s+ (.*)$/xms); |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub parse { |
15
|
77
|
|
|
77
|
0
|
125
|
my ( $self, $l ) = @_; |
16
|
77
|
|
|
|
|
99
|
my $c = $self->{context}; |
17
|
77
|
|
|
|
|
1066
|
my $pattern = $self->pattern; |
18
|
77
|
100
|
|
|
|
430
|
$l =~ $pattern or return $l; |
19
|
|
|
|
|
|
|
|
20
|
43
|
|
|
|
|
80
|
my $space = length($1); |
21
|
43
|
|
100
|
|
|
598
|
my $level = $c->ul->{level} || 0; |
22
|
43
|
|
100
|
|
|
738
|
$c->ul->{space} ||= 0; |
23
|
|
|
|
|
|
|
|
24
|
43
|
100
|
|
|
|
725
|
if ( $space > $c->ul->{space} ) { |
|
|
100
|
|
|
|
|
|
25
|
18
|
|
|
|
|
124
|
for ( 1 .. ( $space + 1 ) / 2 - $level ) { |
26
|
18
|
|
|
|
|
43
|
$l = ' |
27
|
18
|
|
|
|
|
38
|
$level++; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
elsif ( $space < $c->ul->{space} ) { |
31
|
4
|
|
|
|
|
124
|
for ( 1 .. ( $c->ul->{space} - $space ) / 2 ) { |
32
|
6
|
|
|
|
|
40
|
$l = '' . $l; |
33
|
6
|
|
|
|
|
10
|
$level--; |
34
|
|
|
|
|
|
|
} |
35
|
4
|
|
|
|
|
26
|
$l =~ s!(?<=(?:ul|li)>)(?= )!!; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
else { |
38
|
21
|
|
|
|
|
431
|
$l = "$l"; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
43
|
|
|
|
|
672
|
$c->ul( { level => $level, space => $space } ); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# parse inline nodes |
44
|
43
|
|
|
|
|
401
|
$l =~ s{ $pattern }{"" . $self->replace($2)}xmsge; |
|
43
|
|
|
|
|
119
|
|
45
|
|
|
|
|
|
|
|
46
|
43
|
100
|
100
|
|
|
1592
|
if ( $c->hasnext and $c->nextline =~ /$pattern/ ) { |
47
|
34
|
|
|
|
|
80
|
$self->parse($l); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
else { |
50
|
9
|
|
|
|
|
138
|
for ( 1 .. $c->ul->{level} ) { |
51
|
12
|
|
|
|
|
58
|
$l .= ''; |
52
|
|
|
|
|
|
|
} |
53
|
9
|
|
|
|
|
129
|
$c->ul->{level} = 0; |
54
|
9
|
|
|
|
|
146
|
$c->ul->{space} = 0; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# parse inline nodes |
58
|
43
|
|
|
|
|
136
|
$c->htmllines($l); |
59
|
|
|
|
|
|
|
|
60
|
43
|
|
|
|
|
142
|
return; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |