line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Xatena::Node::SuperPre; |
2
|
|
|
|
|
|
|
|
3
|
17
|
|
|
17
|
|
2572
|
use strict; |
|
17
|
|
|
|
|
30
|
|
|
17
|
|
|
|
|
533
|
|
4
|
17
|
|
|
17
|
|
82
|
use warnings; |
|
17
|
|
|
|
|
29
|
|
|
17
|
|
|
|
|
418
|
|
5
|
17
|
|
|
17
|
|
78
|
use base qw(Text::Xatena::Node); |
|
17
|
|
|
|
|
28
|
|
|
17
|
|
|
|
|
790
|
|
6
|
17
|
|
|
17
|
|
97
|
use Text::Xatena::Util; |
|
17
|
|
|
|
|
36
|
|
|
17
|
|
|
|
|
114
|
|
7
|
|
|
|
|
|
|
use constant { |
8
|
17
|
|
|
|
|
5394
|
BEGINNING => qr/^>\|([^|]*)\|$/, |
9
|
|
|
|
|
|
|
ENDOFNODE => qr/^\|\|<$/, |
10
|
17
|
|
|
17
|
|
1780
|
}; |
|
17
|
|
|
|
|
34
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $SUPERPRE_CLASS_NAME = 'code'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub parse { |
15
|
377
|
|
|
377
|
0
|
798
|
my ($class, $s, $parent, $stack) = @_; |
16
|
377
|
100
|
|
|
|
907
|
if ($s->scan(BEGINNING)) { |
17
|
18
|
|
|
|
|
68
|
my $lang = $s->matched->[1]; |
18
|
18
|
|
|
|
|
67
|
my $content = $s->scan_until(ENDOFNODE); |
19
|
18
|
|
|
|
|
37
|
pop @$content; |
20
|
18
|
|
|
|
|
241
|
my $node = $class->new([join("\n", @$content)]); |
21
|
18
|
|
|
|
|
1141
|
$node->{lang} = $lang; |
22
|
18
|
|
|
|
|
781
|
push @$parent, $node; |
23
|
18
|
|
|
|
|
128
|
return 1; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
17
|
|
|
17
|
0
|
48
|
sub lang { $_[0]->{lang} } |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub as_html { |
30
|
17
|
|
|
17
|
0
|
31
|
my ($self, $context, %opts) = @_; |
31
|
17
|
|
|
|
|
77
|
$context->_tmpl(__PACKAGE__, q[ |
32
|
|
|
|
|
|
|
? if ($lang) { |
33
|
|
|
|
|
|
|
{{= $content }} |
34
|
|
|
|
|
|
|
? } else { |
35
|
|
|
|
|
|
|
{{= $content }} |
36
|
|
|
|
|
|
|
? } |
37
|
|
|
|
|
|
|
], { |
38
|
|
|
|
|
|
|
class => $SUPERPRE_CLASS_NAME, |
39
|
|
|
|
|
|
|
lang => $self->lang, |
40
|
17
|
|
|
|
|
61
|
content => escape_html(join "", @{ $self->children }) |
41
|
|
|
|
|
|
|
}); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
__END__ |