lib/Text/Xatena/Node/SuperPre.pm

filter: Statementstmt 100% 30 / 30 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 3 totaltotal 93.0% 40 / 43 CC 2 SCAR 2.0
CC
2
Cov
100%
parse
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« lib/Text/Xatena/Node/SeeMore.pm ↑ Summary blib/lib/Text/Xatena/Node/Root.pm »
1 package Text::Xatena::Node::SuperPre;
2  
3 19 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 19 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 19 ▶use base qw(Text::Xatena::Node);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 19 ▶use Text::Xatena::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 19 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
8 19 BEGINNING => qr/^>\|([^|]*)\|$/,
9 ENDOFNODE => qr/^\|\|<$/,
10 19 };
11  
12 19 our $SUPERPRE_CLASS_NAME = 'code';
13  
14 418 ▶sub parse {
Subroutine parse: called CC=2 SCAR=6.9
Pod undocumented
15 418 my ($class, $s, $parent, $stack) = @_;
16 418 ▶ if ($s->scan(BEGINNING)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s->scan(qr/^>\|([^|]*)\|$/)) 18 400 418
17 18 my $lang = $s->matched->[1];
18 18 my $content = $s->scan_until(ENDOFNODE);
19 18 pop @$content;
20 18 my $node = $class->new([join("\n", @$content)]);
21 18 $node->{lang} = $lang;
22 18 push @$parent, $node;
23 18 return 1;
24 }
25 }
26  
27 17 ▶sub lang { $_[0]->{lang} }
Subroutine lang: called CC=1 SCAR=0.0
Pod undocumented
28  
29 17 ▶sub as_html {
Subroutine as_html: called CC=1 SCAR=0.0
Pod undocumented
30 17 my ($self, $context, %opts) = @_;
31 $context->_tmpl(__PACKAGE__, q[
32 ? if ($lang) {
33 <pre class="{{= $class }} {{= "lang-$lang" }}">{{= $content }}</pre>
34 ? } else {
35 <pre class="{{= $class }}">{{= $content }}</pre>
36 ? }
37 ], {
38 class => $SUPERPRE_CLASS_NAME,
39 lang => $self->lang,
40 17 content => escape_html(join "", @{ $self->children })
41 });
42 }
43  
44 19 1;
45 __END__
« lib/Text/Xatena/Node/SeeMore.pm ↑ Summary blib/lib/Text/Xatena/Node/Root.pm »