line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Trac::Context; |
2
|
9
|
|
|
9
|
|
60
|
use strict; |
|
9
|
|
|
|
|
29
|
|
|
9
|
|
|
|
|
253
|
|
3
|
9
|
|
|
9
|
|
40
|
use warnings; |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
250
|
|
4
|
9
|
|
|
9
|
|
57
|
use base qw (Class::Accessor::Fast); |
|
9
|
|
|
|
|
27
|
|
|
9
|
|
|
|
|
565
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.23'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw( ul ol min_heading_level permalink in_block_of trac_url )); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my %Defaults = ( |
11
|
|
|
|
|
|
|
text => '', |
12
|
|
|
|
|
|
|
html => '', |
13
|
|
|
|
|
|
|
htmllines => [], |
14
|
|
|
|
|
|
|
ul => {}, |
15
|
|
|
|
|
|
|
ol => {}, |
16
|
|
|
|
|
|
|
shift_count => 0, |
17
|
|
|
|
|
|
|
in_block_of => [], |
18
|
|
|
|
|
|
|
disable_links => [], |
19
|
|
|
|
|
|
|
enable_links => [], |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new { |
23
|
120
|
|
|
120
|
1
|
367
|
my ( $class, $args ) = @_; |
24
|
|
|
|
|
|
|
|
25
|
120
|
|
|
|
|
1361
|
my $self = { %Defaults, %$args, }; |
26
|
|
|
|
|
|
|
|
27
|
120
|
|
|
|
|
390
|
bless $self, $class; |
28
|
120
|
|
|
|
|
468
|
$self->init; |
29
|
120
|
|
|
|
|
301
|
return $self; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub init { |
33
|
120
|
|
|
120
|
0
|
226
|
my $self = shift; |
34
|
120
|
|
|
|
|
411
|
$self->{text} =~ s/\r//g; |
35
|
120
|
|
|
|
|
248
|
@{ $self->{lines} } = split( '\n', $self->{text} ); |
|
120
|
|
|
|
|
709
|
|
36
|
120
|
|
|
|
|
324
|
$self->{index} = -1; |
37
|
120
|
|
|
|
|
273
|
$self->{htmllines} = []; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub hasnext { |
41
|
340
|
|
|
340
|
0
|
581
|
my $self = shift; |
42
|
340
|
|
|
|
|
1445
|
defined( $self->{lines}->[ $self->{index} + 1 ] ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub nextline { |
46
|
219
|
|
|
219
|
0
|
377
|
my $self = shift; |
47
|
219
|
|
|
|
|
1165
|
$self->{lines}->[ $self->{index} + 1 ]; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub shiftline { |
51
|
473
|
|
|
473
|
0
|
1095
|
my $self = shift; |
52
|
473
|
|
|
|
|
1905
|
$self->{lines}->[ ++$self->{index} ]; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub unshiftline { |
56
|
113
|
|
|
113
|
0
|
208
|
my $self = shift; |
57
|
113
|
|
|
|
|
301
|
$self->{lines}->[ --$self->{index} ]; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub currentline { |
61
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
62
|
0
|
|
|
|
|
0
|
$self->{lines}->[ $self->{index} ]; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub html { |
66
|
120
|
|
|
120
|
0
|
222
|
my $self = shift; |
67
|
120
|
|
|
|
|
207
|
join( "\n", @{ $self->{htmllines} } ); |
|
120
|
|
|
|
|
1711
|
|
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub htmllines { |
71
|
465
|
|
|
465
|
0
|
973
|
my $self = shift; |
72
|
465
|
100
|
|
|
|
986
|
push @{ $self->{htmllines} }, $_[0] if defined $_[0]; |
|
457
|
|
|
|
|
1085
|
|
73
|
465
|
|
|
|
|
1758
|
$self->{htmllines}; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
0
|
0
|
|
sub lasthtmlline { $_[0]->{htmllines}->[-1]; } |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub list_level { |
79
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |