Parser/Blockquote.pm

filter: Statementstmt 34.4% 20 / 58 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 41.1% 7 / 17 Podpod 100% 5 / 5 totaltotal 36.3% 32 / 88 CC 5 SCAR 21.2
CC
5
Cov
30%
as_string
30.0
init
2.0
append
2.0
CRAP 8.3
« Parser/TableCaption.pm ↑ Summary Parser/Abbr.pm »
1 ## -*- perl -*-
2 ##----------------------------------------------------------------------------
3 ## Markdown Parser Only - ~/lib/Markdown/Parser/Blockquote.pm
4 ## Version v0.3.0
5 ## Copyright(c) 2022 DEGUEST Pte. Ltd.
6 ## Author: Jacques Deguest <jack@deguest.jp>
7 ## Created 2021/08/23
8 ## Modified 2024/08/30
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 1 ▶{
Subroutine BEGIN: called CC=1 SCAR=0.0
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 our $VERSION = 'v0.3.0';
22 };
23  
24 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 sub init
28 0 ▶{
Subroutine init: not called CC=1 SCAR=6.9
Pod documented
29 0 my $self = shift( @_ );
30 0 $self->{tag_name} = 'blockquote';
31 0 return( $self->SUPER::init( @_ ) );
32 }
33  
34 0 ▶sub append { return( shift->_append_text( @_ ) ); }
Subroutine append: not called CC=1 SCAR=6.9
Pod documented
35  
36 sub as_markdown
37 0 ▶{
Subroutine as_markdown: not called CC=1 SCAR=6.9
Pod documented
38 0 my $self = shift( @_ );
39 0 ▶ my $str = $self->children->map(sub{ $_->as_markdown })->join( "\n" );
Subroutine __ANON__: not called CC=1 SCAR=6.9
40 0 my $lines = $str->split( "\n" );
41 $lines->for(sub
42 0 ▶ {
Subroutine __ANON__: not called CC=1 SCAR=6.9
43 0 my( $i, $val ) = @_;
44 0 substr( $lines->[ $i ], 0, 0 ) = '> ';
45 0 });
46 0 return( $lines->join( "\n" )->scalar );
47 }
48  
49 sub as_pod
50 0 ▶{
Subroutine as_pod: not called CC=1 SCAR=6.9
Pod documented
51 0 my $self = shift( @_ );
52 0 ▶ my $str = $self->children->map(sub{ $_->as_pod })->join( "\n" );
Subroutine __ANON__: not called CC=1 SCAR=6.9
53 0 my $lines = $str->split( "\n" );
54 $lines->for(sub
55 0 ▶ {
Subroutine __ANON__: not called CC=1 SCAR=6.9
56 0 my( $i, $val ) = @_;
57 0 substr( $lines->[ $i ], 0, 0 ) = ' ';
58 0 });
59 0 return( $lines->join( "\n" )->scalar );
60 }
61  
62 sub as_string
63 0 ▶{
Subroutine as_string: not called CC=5 SCAR=34.0
Pod documented
64 0 my $self = shift( @_ );
65 0 my $arr = $self->new_array;
66 0 my $tag = $self->tag_name;
67 0 my $tag_open = $tag;
68 0 my $tmp = $self->new_array;
69 0 $tmp->push( "<$tag_open" );
70 0 my $attr = $self->new_array;
71 0 ▶ $attr->push( $self->format_id ) if( $self->id->length );
Branch: 1 branch
BranchTrueFalseTotal
if $self->id->length 0 0 0
72 0 ▶ $attr->push( $self->format_class ) if( $self->class->length );
Branch: 1 branch
BranchTrueFalseTotal
if $self->class->length 0 0 0
73 0 my $attributes = $self->format_attributes;
74 0 ▶ $attr->push( $attributes->join( ' ' )->scalar ) if( $attributes->length );
Branch: 1 branch
BranchTrueFalseTotal
if $attributes->length 0 0 0
75 0 ▶ $tmp->push( ' ' . $attr->join( ' ' )->scalar ) if( $attr->length );
Branch: 1 branch
BranchTrueFalseTotal
if $attr->length 0 0 0
76 0 $tmp->push( '>' );
77 0 $arr->push( $tmp->join( '' )->scalar );
78 $arr->push( $self->children->map(sub
79 0 ▶ {
Subroutine __ANON__: not called CC=1 SCAR=6.9
80 0 $_->as_string;
81 0 })->list );
82 0 $arr->push( "</$tag>\n" );
83 0 return( $arr->join( "\n" )->scalar );
84 }
85  
86 1 1;
87 # NOTE: POD
88 __END__
« Parser/TableCaption.pm ↑ Summary Parser/Abbr.pm »