lib/Markdown/Parser/Blockquote.pm

filter: Statementstmt 37.7% 23 / 61 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 44.4% 8 / 18 Podpod 100% 5 / 5 totaltotal 39.1% 36 / 92 CC 5 SCAR 20.8
CC
5
Cov
33%
as_string
30.0
init
2.0
append
2.0
CRAP 8.0
« lib/Markdown/Parser/Paragraph.pm ↑ Summary blib/lib/Markdown/Parser/Abbr.pm »
1 ## -*- perl -*-
2 ##----------------------------------------------------------------------------
3 ## Markdown Parser Only - ~/lib/Markdown/Parser/Blockquote.pm
4 ## Version v0.2.0
5 ## Copyright(c) 2021 DEGUEST Pte. Ltd.
6 ## Author: Jacques Deguest <jack@deguest.jp>
7 ## Created 2021/08/23
8 ## Modified 2022/09/19
9 ## All rights reserved
10 ##
11 ## This program is free software; you can redistribute it and/or modify it
12 ## under the same terms as Perl itself.
13 ##----------------------------------------------------------------------------
14 package Markdown::Parser::Blockquote;
15 BEGIN
16 {
17 1 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶ use parent qw( Markdown::Parser::Element );
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶ use vars qw( $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶ use Devel::Confess;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶ our $VERSION = 'v0.2.0';
Subroutine BEGIN: called CC=1 SCAR=0.0
23 };
24  
25 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 sub init
29 {
30 0 ▶ my $self = shift( @_ );
Subroutine init: not called CC=1 SCAR=6.9
Pod documented
31 0 $self->{tag_name} = 'blockquote';
32 0 return( $self->SUPER::init( @_ ) );
33 }
34  
35 0 ▶sub append { return( shift->_append_text( @_ ) ); }
Subroutine append: not called CC=1 SCAR=6.9
Pod documented
36  
37 sub as_markdown
38 {
39 0 ▶ my $self = shift( @_ );
Subroutine as_markdown: not called CC=1 SCAR=6.9
Pod documented
40 0 ▶ my $str = $self->children->map(sub{ $_->as_markdown })->join( "\n" );
Subroutine __ANON__: not called CC=1 SCAR=6.9
41 0 my $lines = $str->split( "\n" );
42 $lines->for(sub
43 {
44 0 ▶ my( $i, $val ) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
45 0 substr( $lines->[ $i ], 0, 0 ) = '> ';
46 0 });
47 0 return( $lines->join( "\n" )->scalar );
48 }
49  
50 sub as_pod
51 {
52 0 ▶ my $self = shift( @_ );
Subroutine as_pod: not called CC=1 SCAR=6.9
Pod documented
53 0 ▶ my $str = $self->children->map(sub{ $_->as_pod })->join( "\n" );
Subroutine __ANON__: not called CC=1 SCAR=6.9
54 0 my $lines = $str->split( "\n" );
55 $lines->for(sub
56 {
57 0 ▶ my( $i, $val ) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
58 0 substr( $lines->[ $i ], 0, 0 ) = ' ';
59 0 });
60 0 return( $lines->join( "\n" )->scalar );
61 }
62  
63 sub as_string
64 {
65 0 ▶ my $self = shift( @_ );
Subroutine as_string: not called CC=5 SCAR=34.0
Pod documented
66 0 my $arr = $self->new_array;
67 0 my $tag = $self->tag_name;
68 0 my $tag_open = $tag;
69 0 my $tmp = $self->new_array;
70 0 $tmp->push( "<$tag_open" );
71 0 my $attr = $self->new_array;
72 0 ▶ $attr->push( $self->format_id ) if( $self->id->length );
Branch: 1 branch
BranchTrueFalseTotal
if $self->id->length 0 0 0
73 0 ▶ $attr->push( $self->format_class ) if( $self->class->length );
Branch: 1 branch
BranchTrueFalseTotal
if $self->class->length 0 0 0
74 0 my $attributes = $self->format_attributes;
75 0 ▶ $attr->push( $attributes->join( ' ' )->scalar ) if( $attributes->length );
Branch: 1 branch
BranchTrueFalseTotal
if $attributes->length 0 0 0
76 0 ▶ $tmp->push( ' ' . $attr->join( ' ' )->scalar ) if( $attr->length );
Branch: 1 branch
BranchTrueFalseTotal
if $attr->length 0 0 0
77 0 $tmp->push( '>' );
78 0 $arr->push( $tmp->join( '' )->scalar );
79 $arr->push( $self->children->map(sub
80 {
81 0 ▶ $_->as_string;
Subroutine __ANON__: not called CC=1 SCAR=6.9
82 0 })->list );
83 0 $arr->push( "</$tag>\n" );
84 0 return( $arr->join( "\n" )->scalar );
85 }
86  
87 1 1;
88 # NOTE: POD
89 __END__
« lib/Markdown/Parser/Paragraph.pm ↑ Summary blib/lib/Markdown/Parser/Abbr.pm »