line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Trac::Blockquote; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
60
|
use strict; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
242
|
|
4
|
8
|
|
|
8
|
|
42
|
use warnings; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
219
|
|
5
|
8
|
|
|
8
|
|
41
|
use base qw( Text::Trac::BlockNode ); |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
42
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.22'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub init { |
10
|
220
|
|
|
220
|
0
|
476
|
my $self = shift; |
11
|
220
|
|
|
|
|
4446
|
$self->pattern(qr/^(?:>|\s+(?![*\s]|[\daiAI]\.\ +).+$)/); |
12
|
220
|
|
|
|
|
1972
|
$self->block_nodes( [qw( heading p ul ol )] ); |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub parse { |
16
|
7
|
|
|
7
|
0
|
21
|
my ( $self, $l ) = @_; |
17
|
7
|
|
|
|
|
19
|
my $c = $self->{context}; |
18
|
7
|
|
|
|
|
122
|
my $pattern = $self->pattern; |
19
|
7
|
100
|
|
|
|
50
|
return if $l =~ /::$/; |
20
|
|
|
|
|
|
|
|
21
|
4
|
100
|
|
|
|
20
|
if ( $l =~ /^(>+).+/ ) { |
22
|
2
|
|
|
|
|
6
|
my $depth = length $1; |
23
|
2
|
|
|
|
|
3
|
my $blockquote_depth = 0; |
24
|
2
|
|
|
|
|
5
|
for ( @{ $c->in_block_of } ) { |
|
2
|
|
|
|
|
33
|
|
25
|
0
|
0
|
|
|
|
0
|
$blockquote_depth++ if $_ eq 'blockquote'; |
26
|
|
|
|
|
|
|
} |
27
|
2
|
50
|
|
|
|
16
|
my $class = $c->{class} ? q{class="citation"} : ''; |
28
|
|
|
|
|
|
|
|
29
|
2
|
50
|
|
|
|
10
|
if ( $depth > $blockquote_depth ) { |
30
|
2
|
|
|
|
|
8
|
for ( 1 .. $depth ) { |
31
|
4
|
|
|
|
|
26
|
$c->htmllines(qq{}); |
32
|
4
|
|
|
|
|
7
|
push @{ $c->in_block_of }, 'blockquote'; |
|
4
|
|
|
|
|
68
|
|
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
else { |
37
|
2
|
|
|
|
|
9
|
$c->htmllines(''); |
38
|
2
|
|
|
|
|
4
|
push @{ $c->in_block_of }, 'blockquote'; |
|
2
|
|
|
|
|
35
|
|
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
4
|
|
|
|
|
31
|
$c->unshiftline; |
42
|
4
|
|
|
|
|
12
|
while ( $c->hasnext ) { |
43
|
9
|
100
|
|
|
|
28
|
last if ( $c->nextline =~ /^\s*$/ ); |
44
|
8
|
|
|
|
|
22
|
my $l = $c->shiftline; |
45
|
|
|
|
|
|
|
|
46
|
8
|
100
|
|
|
|
29
|
if ( $l =~ /^(>+).+/ ) { |
47
|
3
|
|
|
|
|
8
|
my $depth = length $1; |
48
|
3
|
|
|
|
|
6
|
my $blockquote_depth = 0; |
49
|
3
|
|
|
|
|
6
|
for ( @{ $c->in_block_of } ) { |
|
3
|
|
|
|
|
53
|
|
50
|
5
|
50
|
|
|
|
27
|
$blockquote_depth++ if $_ eq 'blockquote'; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
3
|
50
|
|
|
|
11
|
if ( $depth < $blockquote_depth ) { |
54
|
0
|
|
|
|
|
0
|
$c->unshiftline; |
55
|
0
|
|
|
|
|
0
|
last; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# parse other block nodes |
60
|
8
|
|
|
|
|
27
|
my $block_parsers = $self->_get_matched_parsers( 'block', $l ); |
61
|
8
|
|
|
|
|
17
|
for my $parser ( @{$block_parsers} ) { |
|
8
|
|
|
|
|
19
|
|
62
|
8
|
|
|
|
|
34
|
$l = $parser->parse($l); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# parse inline nodes |
66
|
8
|
50
|
|
|
|
22
|
my $inline_parsers = $l ? $self->_get_matched_parsers( 'inline', $l ) : undef; |
67
|
8
|
|
|
|
|
14
|
for my $parser ( @{$inline_parsers} ) { |
|
8
|
|
|
|
|
20
|
|
68
|
0
|
|
|
|
|
0
|
$l = $parser->parse($l); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
8
|
|
|
|
|
22
|
$c->htmllines($l); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
4
|
100
|
66
|
|
|
52
|
if ( @{ $c->in_block_of } and $c->in_block_of->[-1] eq 'blockquote' ) { |
|
4
|
|
|
|
|
108
|
|
75
|
2
|
|
|
|
|
61
|
pop @{ $c->in_block_of }; |
|
2
|
|
|
|
|
35
|
|
76
|
2
|
|
|
|
|
14
|
$c->htmllines(''); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
4
|
|
|
|
|
36
|
return $l; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |