Parser/Paragraph.pm

filter: Statementstmt 55.1% 27 / 49 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 71.4% 10 / 14 Podpod 100% 4 / 4 totaltotal 54.6% 41 / 75 CC 5 SCAR 22.2
CC
5
Cov
47%
as_string
30.0
as_pod
2.0
__ANON__
2.0
CRAP 9.2
« Parser/TableHeader.pm ↑ Summary Parser/TableCaption.pm »
1 ##----------------------------------------------------------------------------
2 ## Markdown Parser Only - ~/lib/Markdown/Parser/Paragraph.pm
3 ## Version v0.3.0
4 ## Copyright(c) 2022 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2021/08/23
7 ## Modified 2024/08/30
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 2 ▶{
Subroutine BEGIN: called CC=1 SCAR=0.0
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 our $VERSION = 'v0.3.0';
21 };
22  
23 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 sub init
27 1 ▶{
Subroutine init: called CC=1 SCAR=0.0
Pod documented
28 1 my $self = shift( @_ );
29 1 $self->{tag_name} = 'p';
30 1 return( $self->SUPER::init( @_ ) );
31 }
32  
33 sub as_markdown
34 1 ▶{
Subroutine as_markdown: called CC=1 SCAR=0.0
Pod documented
35 1 my $self = shift( @_ );
36 1 ▶ my $str = $self->children->map(sub{ $_->as_markdown })->join( '' );
Subroutine __ANON__: called CC=1 SCAR=0.0
37 # Add an additional new line
38 1 return( "$str\n" );
39 }
40  
41 # Basically, same as markdown
42 sub as_pod
43 0 ▶{
Subroutine as_pod: not called CC=1 SCAR=6.9
Pod documented
44 0 my $self = shift( @_ );
45 0 ▶ my $str = $self->children->map(sub{ $_->as_pod })->join( '' );
Subroutine __ANON__: not called CC=1 SCAR=6.9
46 # Add an additional new line
47 0 return( "$str\n" );
48 }
49  
50 sub as_string
51 0 ▶{
Subroutine as_string: not called CC=5 SCAR=34.0
Pod documented
52 0 my $self = shift( @_ );
53 0 my $tag = 'p';
54 0 my $tag_open = $tag;
55 0 my $arr = $self->new_array;
56 0 my $tmp = $self->new_array;
57 0 $tmp->push( "<$tag_open" );
58 0 my $attr = $self->new_array;
59 0 ▶ $attr->push( $self->format_id ) if( $self->id->length );
Branch: 1 branch
BranchTrueFalseTotal
if $self->id->length 0 0 0
60 0 ▶ $attr->push( $self->format_class ) if( $self->class->length );
Branch: 1 branch
BranchTrueFalseTotal
if $self->class->length 0 0 0
61 0 my $attributes = $self->format_attributes;
62 0 ▶ $attr->push( $attributes->join( ' ' )->scalar ) if( $attributes->length );
Branch: 1 branch
BranchTrueFalseTotal
if $attributes->length 0 0 0
63 0 ▶ $tmp->push( ' ' . $attr->join( ' ' )->scalar ) if( $attr->length );
Branch: 1 branch
BranchTrueFalseTotal
if $attr->length 0 0 0
64 0 $tmp->push( '>' );
65 0 $arr->push( $tmp->join( '' )->scalar );
66 0 ▶ $arr->push( $self->children->map(sub{ $_->as_string })->join( '' )->scalar );
Subroutine __ANON__: not called CC=1 SCAR=6.9
67 0 $arr->push( "</$tag>" );
68 ## return( $arr->join( $self->children->length > 1 ? "\n" : '' )->scalar );
69 0 return( $arr->join( "\n" )->scalar );
70 }
71  
72 2 1;
73 # NOTE: POD
74 __END__
« Parser/TableHeader.pm ↑ Summary Parser/TableCaption.pm »