Parser/Bold.pm

filter: Statementstmt 38.4% 20 / 52 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 46.6% 7 / 15 Podpod 100% 5 / 5 totaltotal 34.0% 32 / 94 CC 10 SCAR 28.6
CC
10
Cov
28%
as_string
42.0
as_markdown
30.0
init
2.0
CRAP 17.5
« Parser/Header.pm ↑ Summary Parser/Emphasis.pm »
1 ## -*- perl -*-
2 ##----------------------------------------------------------------------------
3 ## Markdown Parser Only - ~/lib/Markdown/Parser/Bold.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::Bold;
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} = 'bold';
31 0 $self->{type} = '';
32 0 return( $self->SUPER::init( @_ ) );
33 }
34  
35 sub as_markdown
36 0 ▶{
Subroutine as_markdown: not called CC=5 SCAR=34.0
Pod documented
37 0 my $self = shift( @_ );
38 0 ▶ my $str = $self->children->map(sub{ $_->as_markdown })->join( '' );
Subroutine __ANON__: not called CC=1 SCAR=6.9
39 0 ▶ my $type = $self->type // '**';
Condition0%0/2
$self->type // "**"
l!l
00
MC/DC0%0/1
$self->type // "**"
$self->type
Truth table0%0/2
A
A= $self->type
Aresult
11
00
40 0 ▶ $type .= $type if( length( $type ) == 1 );
Branch: 1 branch
BranchTrueFalseTotal
if length $type == 1 0 0 0
41 0 ▶ $type = '**' if( $type ne '**' && $type ne '__' );
Branch: 1 branch
BranchTrueFalseTotal
if $type ne "**" and $type ne "__" 0 0 0
Condition0%0/3
$type ne "**" and $type ne "__"
!ll&&!rl&&r
000
MC/DC0%0/2
$type ne "**" and $type ne "__"
$type ne "**" $type ne "__"
Truth table0%0/3
A and B
A= $type ne "**"B= $type ne "__"
ABresult
0X0
100
111
42 0 return( "${type}${str}${type}" );
43 }
44  
45 sub as_pod
46 0 ▶{
Subroutine as_pod: not called CC=1 SCAR=6.9
Pod documented
47 0 my $self = shift( @_ );
48 0 ▶ my $str = $self->children->map(sub{ $_->as_pod })->join( '' );
Subroutine __ANON__: not called CC=1 SCAR=6.9
49 0 return( "B<${str}>" );
50 }
51  
52 sub as_string
53 0 ▶{
Subroutine as_string: not called CC=6 SCAR=37.4
Pod documented
54 0 my $self = shift( @_ );
55 0 my $arr = $self->new_array;
56 0 my $tag = 'strong';
57 0 my $tag_open = $tag;
58 0 $arr->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 ▶ $arr->push( ' ' . $attr->join( ' ' )->scalar ) if( $attr->length );
Branch: 1 branch
BranchTrueFalseTotal
if $attr->length 0 0 0
65 0 $arr->push( ">" );
66 0 ▶ $arr->push( $self->children->map(sub{ $_->as_string })->list ) if( $self->children->length );
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if $self->children->length 0 0 0
67 0 $arr->push( "</${tag}>" );
68 0 return( $arr->join( '' )->scalar );
69 }
70  
71 0 ▶sub type { return( shift->_set_get_scalar_as_object( 'type', @_ ) ); }
Subroutine type: not called CC=1 SCAR=6.9
Pod documented
72  
73 1 1;
74 # NOTE: POD
75 __END__
« Parser/Header.pm ↑ Summary Parser/Emphasis.pm »