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