line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Trac::BlockNode; |
2
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
50
|
use strict; |
|
9
|
|
|
|
|
22
|
|
|
9
|
|
|
|
|
214
|
|
4
|
9
|
|
|
9
|
|
37
|
use warnings; |
|
9
|
|
|
|
|
14
|
|
|
9
|
|
|
|
|
217
|
|
5
|
|
|
|
|
|
|
|
6
|
9
|
|
|
9
|
|
37
|
use base qw( Class::Accessor::Fast Class::Data::Inheritable ); |
|
9
|
|
|
|
|
14
|
|
|
9
|
|
|
|
|
437
|
|
7
|
9
|
|
|
9
|
|
9810
|
use UNIVERSAL::require; |
|
9
|
|
|
|
|
8296
|
|
|
9
|
|
|
|
|
67
|
|
8
|
9
|
|
|
9
|
|
3510
|
use Text::Trac::InlineNode; |
|
9
|
|
|
|
|
28
|
|
|
9
|
|
|
|
|
70
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.24'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
__PACKAGE__->mk_classdata( block_nodes => [qw( heading hr p ul ol blockquote pre table dl )] ); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
#__PACKAGE__->mk_classdata( |
15
|
|
|
|
|
|
|
# inline_nodes => [ qw( bold_italic bold italic underline monospace strike sup sub br |
16
|
|
|
|
|
|
|
# auto_link_http macro trac_links ) ] |
17
|
|
|
|
|
|
|
#); |
18
|
|
|
|
|
|
|
__PACKAGE__->mk_classdata( block_parsers => [] ); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
__PACKAGE__->mk_classdata( inline_parsers => [] ); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw( context pattern inline_parser )); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub new { |
25
|
1607
|
|
|
1607
|
1
|
8871
|
my ( $class, $params ) = @_; |
26
|
1607
|
|
|
|
|
4313
|
my $self = { %$params, }; |
27
|
1607
|
|
|
|
|
2652
|
bless $self, $class; |
28
|
1607
|
|
|
|
|
5321
|
$self->init; |
29
|
1607
|
|
|
|
|
27786
|
$self->inline_parser( Text::Trac::InlineNode->new( $self->context ) ); |
30
|
1607
|
|
|
|
|
12411
|
return $self; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub init { |
34
|
447
|
|
|
447
|
0
|
610
|
my $self = shift; |
35
|
447
|
|
|
|
|
600
|
return $self; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub parse { |
39
|
120
|
|
|
120
|
0
|
211
|
my $self = shift; |
40
|
120
|
|
|
|
|
1882
|
my $c = $self->context; |
41
|
|
|
|
|
|
|
|
42
|
120
|
|
|
|
|
865
|
$self->block_parsers( $self->_get_parsers('block') ); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
#$self->inline_parsers( $self->_get_parsers('inline') ); |
45
|
|
|
|
|
|
|
|
46
|
120
|
|
|
|
|
7325
|
while ( defined( my $l = $c->shiftline ) ) { |
47
|
205
|
100
|
|
|
|
646
|
next if $l =~ /^$/; |
48
|
198
|
|
|
|
|
282
|
for my $parser ( @{ $self->_get_matched_parsers( 'block', $l ) } ) { |
|
198
|
|
|
|
|
477
|
|
49
|
201
|
|
|
|
|
638
|
$parser->parse($l); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub escape { |
55
|
4
|
|
|
4
|
0
|
8
|
my ( $self, $l ) = @_; |
56
|
4
|
|
|
|
|
60
|
return $self->inline_parser->escape($l); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub replace { |
60
|
210
|
|
|
210
|
0
|
513
|
my ( $self, $l ) = @_; |
61
|
210
|
|
|
|
|
3159
|
return $self->inline_parser->parse($l); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub _get_parsers { |
65
|
220
|
|
|
220
|
|
511
|
my ( $self, $type ) = @_; |
66
|
|
|
|
|
|
|
|
67
|
220
|
|
|
|
|
419
|
$type .= '_nodes'; |
68
|
220
|
|
|
|
|
299
|
my @parsers; |
69
|
220
|
|
|
|
|
326
|
for ( @{ $self->$type } ) { |
|
220
|
|
|
|
|
695
|
|
70
|
1280
|
|
|
|
|
4050
|
my $class = 'Text::Trac::' . $self->_camelize($_); |
71
|
1280
|
|
|
|
|
4788
|
$class->require; |
72
|
1280
|
|
|
|
|
48170
|
push @parsers, $class->new( { context => $self->context } ); |
73
|
|
|
|
|
|
|
} |
74
|
220
|
|
|
|
|
1064
|
return \@parsers; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub _get_matched_parsers { |
78
|
314
|
|
|
314
|
|
644
|
my ( $self, $type, $l ) = @_; |
79
|
314
|
|
|
|
|
5016
|
my $c = $self->context; |
80
|
314
|
|
|
|
|
1481
|
$type .= '_parsers'; |
81
|
|
|
|
|
|
|
|
82
|
314
|
|
|
|
|
436
|
my @matched_parsers; |
83
|
|
|
|
|
|
|
|
84
|
314
|
|
|
|
|
376
|
for my $parser ( @{ $self->$type } ) { |
|
314
|
|
|
|
|
890
|
|
85
|
|
|
|
|
|
|
next |
86
|
2070
|
100
|
66
|
|
|
4788
|
if ( grep { ref($parser) eq 'Text::Trac::' . $self->_camelize($_) } @{ $c->in_block_of } |
|
314
|
|
|
|
|
1281
|
|
|
2070
|
|
|
|
|
28273
|
|
87
|
|
|
|
|
|
|
and $type =~ /^block/ ); |
88
|
2055
|
100
|
|
|
|
34030
|
my $pattern = $parser->pattern or next; |
89
|
|
|
|
|
|
|
|
90
|
1849
|
100
|
|
|
|
10825
|
if ( $l =~ /$pattern/ ) { |
91
|
110
|
|
|
|
|
238
|
push @matched_parsers, $parser; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
314
|
100
|
66
|
|
|
4257
|
push @matched_parsers, Text::Trac::P->new( { context => $self->context } ) |
96
|
|
|
|
|
|
|
if ( !@matched_parsers and $type =~ /^block/ ); |
97
|
314
|
|
|
|
|
1034
|
return \@matched_parsers; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub _camelize { |
101
|
1594
|
|
|
1594
|
|
2702
|
my ( $self, $word ) = @_; |
102
|
|
|
|
|
|
|
|
103
|
1594
|
|
|
|
|
1786
|
my $camelized_word; |
104
|
1594
|
|
|
|
|
3622
|
for ( split '_', $word ) { |
105
|
1594
|
|
|
|
|
2104
|
chomp($_); |
106
|
1594
|
|
|
|
|
3115
|
$camelized_word .= ucfirst($_); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
1594
|
|
|
|
|
3775
|
return $camelized_word; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |