lib/Markdown/Parser/Superscript.pm

filter: Statementstmt 46.0% 23 / 50 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 53.3% 8 / 15 Podpod 100% 4 / 4 totaltotal 44.3% 35 / 79 CC 6 SCAR 26.1
CC
6
Cov
38%
as_string
42.0
init
2.0
as_markdown
2.0
CRAP 13.6
« lib/Markdown/Parser/Subscript.pm ↑ Summary lib/Markdown/Parser/Insertion.pm »
1 ## -*- perl -*-
2 ##----------------------------------------------------------------------------
3 ## Markdown Parser Only - ~/lib/Markdown/Parser/Superscript.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::Superscript;
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} = 'sup';
32 0 return( $self->SUPER::init( @_ ) );
33 }
34  
35 sub as_markdown
36 {
37 0 ▶ my $self = shift( @_ );
Subroutine as_markdown: not called CC=1 SCAR=6.9
Pod documented
38 0 ▶ my $str = $self->children->map(sub{ $_->as_markdown })->join( '' );
Subroutine __ANON__: not called CC=1 SCAR=6.9
39 0 return( "^${str}^" );
40 }
41  
42 sub as_pod
43 {
44 0 ▶ my $self = shift( @_ );
Subroutine as_pod: not called CC=1 SCAR=6.9
Pod documented
45 0 ▶ my $str = $self->children->map(sub{ $_->as_pod })->join( '' );
Subroutine __ANON__: not called CC=1 SCAR=6.9
46 0 return( "${str}" );
47 }
48  
49 sub as_string
50 {
51 0 ▶ my $self = shift( @_ );
Subroutine as_string: not called CC=6 SCAR=37.4
Pod documented
52 0 my $arr = $self->new_array;
53 0 my $tag = $self->tag_name;
54 0 my $tag_open = $tag;
55 0 $arr->push( "<${tag_open}" );
56 0 my $attr = $self->new_array;
57 0 ▶ $attr->push( $self->format_id ) if( $self->id->length );
Branch: 1 branch
BranchTrueFalseTotal
if $self->id->length 0 0 0
58 0 ▶ $attr->push( $self->format_class ) if( $self->class->length );
Branch: 1 branch
BranchTrueFalseTotal
if $self->class->length 0 0 0
59 0 my $attributes = $self->format_attributes;
60 0 ▶ $attr->push( $attributes->join( ' ' )->scalar ) if( $attributes->length );
Branch: 1 branch
BranchTrueFalseTotal
if $attributes->length 0 0 0
61 0 ▶ $arr->push( ' ' . $attr->join( ' ' )->scalar ) if( $attr->length );
Branch: 1 branch
BranchTrueFalseTotal
if $attr->length 0 0 0
62 0 $arr->push( '>' );
63 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
64 0 $arr->push( "</${tag}>" );
65 0 return( $arr->join( '' )->scalar );
66 }
67  
68 1 1;
69 # NOTE: POD
70 __END__
« lib/Markdown/Parser/Subscript.pm ↑ Summary lib/Markdown/Parser/Insertion.pm »