line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Trac::Context; |
2
|
9
|
|
|
9
|
|
51
|
use strict; |
|
9
|
|
|
|
|
15
|
|
|
9
|
|
|
|
|
199
|
|
3
|
9
|
|
|
9
|
|
35
|
use warnings; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
188
|
|
4
|
9
|
|
|
9
|
|
35
|
use base qw (Class::Accessor::Fast); |
|
9
|
|
|
|
|
12
|
|
|
9
|
|
|
|
|
472
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.24'; |
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
|
356
|
my ( $class, $args ) = @_; |
24
|
|
|
|
|
|
|
|
25
|
120
|
|
|
|
|
1074
|
my $self = { %Defaults, %$args, }; |
26
|
|
|
|
|
|
|
|
27
|
120
|
|
|
|
|
315
|
bless $self, $class; |
28
|
120
|
|
|
|
|
412
|
$self->init; |
29
|
120
|
|
|
|
|
283
|
return $self; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub init { |
33
|
120
|
|
|
120
|
0
|
194
|
my $self = shift; |
34
|
120
|
|
|
|
|
380
|
$self->{text} =~ s/\r//g; |
35
|
120
|
|
|
|
|
229
|
@{ $self->{lines} } = split( '\n', $self->{text} ); |
|
120
|
|
|
|
|
648
|
|
36
|
120
|
|
|
|
|
326
|
$self->{index} = -1; |
37
|
120
|
|
|
|
|
245
|
$self->{htmllines} = []; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub hasnext { |
41
|
340
|
|
|
340
|
0
|
491
|
my $self = shift; |
42
|
340
|
|
|
|
|
1268
|
defined( $self->{lines}->[ $self->{index} + 1 ] ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub nextline { |
46
|
219
|
|
|
219
|
0
|
300
|
my $self = shift; |
47
|
219
|
|
|
|
|
1058
|
$self->{lines}->[ $self->{index} + 1 ]; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub shiftline { |
51
|
473
|
|
|
473
|
0
|
683
|
my $self = shift; |
52
|
473
|
|
|
|
|
1791
|
$self->{lines}->[ ++$self->{index} ]; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub unshiftline { |
56
|
113
|
|
|
113
|
0
|
203
|
my $self = shift; |
57
|
113
|
|
|
|
|
275
|
$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
|
204
|
my $self = shift; |
67
|
120
|
|
|
|
|
170
|
join( "\n", @{ $self->{htmllines} } ); |
|
120
|
|
|
|
|
1599
|
|
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub htmllines { |
71
|
465
|
|
|
465
|
0
|
773
|
my $self = shift; |
72
|
465
|
100
|
|
|
|
846
|
push @{ $self->{htmllines} }, $_[0] if defined $_[0]; |
|
457
|
|
|
|
|
940
|
|
73
|
465
|
|
|
|
|
1479
|
$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; |