line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Trac::Context; |
2
|
9
|
|
|
9
|
|
59
|
use strict; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
243
|
|
3
|
9
|
|
|
9
|
|
44
|
use warnings; |
|
9
|
|
|
|
|
15
|
|
|
9
|
|
|
|
|
226
|
|
4
|
9
|
|
|
9
|
|
43
|
use base qw (Class::Accessor::Fast); |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
553
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.22'; |
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
|
343
|
my ( $class, $args ) = @_; |
24
|
|
|
|
|
|
|
|
25
|
120
|
|
|
|
|
1228
|
my $self = { %Defaults, %$args, }; |
26
|
|
|
|
|
|
|
|
27
|
120
|
|
|
|
|
361
|
bless $self, $class; |
28
|
120
|
|
|
|
|
480
|
$self->init; |
29
|
120
|
|
|
|
|
314
|
return $self; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub init { |
33
|
120
|
|
|
120
|
0
|
215
|
my $self = shift; |
34
|
120
|
|
|
|
|
361
|
$self->{text} =~ s/\r//g; |
35
|
120
|
|
|
|
|
213
|
@{ $self->{lines} } = split( '\n', $self->{text} ); |
|
120
|
|
|
|
|
704
|
|
36
|
120
|
|
|
|
|
283
|
$self->{index} = -1; |
37
|
120
|
|
|
|
|
267
|
$self->{htmllines} = []; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub hasnext { |
41
|
340
|
|
|
340
|
0
|
593
|
my $self = shift; |
42
|
340
|
|
|
|
|
1408
|
defined( $self->{lines}->[ $self->{index} + 1 ] ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub nextline { |
46
|
219
|
|
|
219
|
0
|
380
|
my $self = shift; |
47
|
219
|
|
|
|
|
1183
|
$self->{lines}->[ $self->{index} + 1 ]; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub shiftline { |
51
|
473
|
|
|
473
|
0
|
851
|
my $self = shift; |
52
|
473
|
|
|
|
|
1913
|
$self->{lines}->[ ++$self->{index} ]; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub unshiftline { |
56
|
113
|
|
|
113
|
0
|
214
|
my $self = shift; |
57
|
113
|
|
|
|
|
299
|
$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
|
215
|
my $self = shift; |
67
|
120
|
|
|
|
|
199
|
join( "\n", @{ $self->{htmllines} } ); |
|
120
|
|
|
|
|
1722
|
|
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub htmllines { |
71
|
465
|
|
|
465
|
0
|
909
|
my $self = shift; |
72
|
465
|
100
|
|
|
|
985
|
push @{ $self->{htmllines} }, $_[0] if defined $_[0]; |
|
457
|
|
|
|
|
1151
|
|
73
|
465
|
|
|
|
|
1752
|
$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; |