lib/Markdown/Parser/Paragraph.pm

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