line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Xatena::Node::Blockquote; |
2
|
|
|
|
|
|
|
|
3
|
17
|
|
|
17
|
|
271
|
use strict; |
|
17
|
|
|
|
|
32
|
|
|
17
|
|
|
|
|
1064
|
|
4
|
17
|
|
|
17
|
|
79
|
use warnings; |
|
17
|
|
|
|
|
254
|
|
|
17
|
|
|
|
|
1017
|
|
5
|
17
|
|
|
17
|
|
80
|
use base qw(Text::Xatena::Node); |
|
17
|
|
|
|
|
31
|
|
|
17
|
|
|
|
|
284
|
|
6
|
|
|
|
|
|
|
use constant { |
7
|
17
|
|
|
|
|
6815
|
BEGINNING => qr/^>(.*?)>$/, |
8
|
|
|
|
|
|
|
ENDOFNODE => qr/^<<$/, |
9
|
17
|
|
|
17
|
|
95
|
}; |
|
17
|
|
|
|
|
46
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub parse { |
12
|
350
|
|
|
350
|
0
|
611
|
my ($class, $s, $parent, $stack) = @_; |
13
|
350
|
100
|
|
|
|
914
|
if ($s->scan(BEGINNING)) { |
14
|
6
|
|
|
|
|
41
|
my $node = $class->new; |
15
|
6
|
|
|
|
|
32
|
$node->{beginning} = $s->matched; |
16
|
6
|
|
|
|
|
26
|
push @$parent, $node; |
17
|
6
|
|
|
|
|
15
|
push @$stack, $node; |
18
|
6
|
|
|
|
|
46
|
return 1; |
19
|
|
|
|
|
|
|
} |
20
|
344
|
100
|
|
|
|
855
|
if ($s->scan(ENDOFNODE)) { |
21
|
6
|
|
|
|
|
28
|
pop @$stack while ref($stack->[-1]) eq 'Text::Xatena::Node::Section'; |
22
|
6
|
|
|
|
|
11
|
my $node = pop @$stack; |
23
|
6
|
50
|
|
|
|
24
|
ref($node) eq $class or warn sprintf("syntax error: unmatched syntax got:%s expected:%s", ref($node), $class); |
24
|
6
|
|
|
|
|
27
|
$node->{endofnode} = $s->matched; |
25
|
6
|
|
|
|
|
49
|
return 1; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub as_html { |
30
|
2
|
|
|
2
|
0
|
6
|
my ($self, $context, %opts) = @_; |
31
|
|
|
|
|
|
|
|
32
|
2
|
|
|
|
|
7
|
my $text = $self->{beginning}->[1]; |
33
|
|
|
|
|
|
|
|
34
|
2
|
100
|
|
|
|
15
|
my $title = ($text =~ /^http/) ? |
35
|
|
|
|
|
|
|
$context->inline->format('[' . $text . ']'): |
36
|
|
|
|
|
|
|
$context->inline->format($text); |
37
|
|
|
|
|
|
|
|
38
|
2
|
|
|
|
|
9
|
my ($uri) = ($title =~ m{(https?://[^\s"':]+)}); |
39
|
|
|
|
|
|
|
|
40
|
2
|
|
|
|
|
37
|
$context->_tmpl(__PACKAGE__, q[ |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
{{= $content }} |
43
|
|
|
|
|
|
|
{{ if ($title) { }} |
44
|
|
|
|
|
|
|
{{= $title }} |
45
|
|
|
|
|
|
|
{{ } }} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
], { |
48
|
|
|
|
|
|
|
cite => $uri, |
49
|
|
|
|
|
|
|
title => $title, |
50
|
|
|
|
|
|
|
content => $self->SUPER::as_html($context, %opts), |
51
|
|
|
|
|
|
|
}); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
__END__ |