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