lib/Markdown/Parser/HTML.pm

filter: Statementstmt 69.3% 34 / 49 Branchbran 25.0% 2 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 78.5% 11 / 14 Podpod 100% 6 / 6 totaltotal 64.6% 53 / 82 CC 6 SCAR 17.2
CC
6
Cov
60%
as_string
20.0
object
4.1
as_pod
2.0
CRAP 5.6
« lib/Markdown/Parser/Abbr.pm ↑ Summary blib/lib/Markdown/Parser/HTML.pm »
1 ##----------------------------------------------------------------------------
2 ## Markdown Parser Only - ~/lib/Markdown/Parser/HTML.pm
3 ## Version v0.2.1
4 ## Copyright(c) 2022 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2021/08/23
7 ## Modified 2022/09/22
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::HTML;
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.1';
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->{is_comment} = 0;
31 # HTML::Object::Element object
32 1 $self->{object} = '';
33 1 $self->{tag_name} = 'html';
34 1 return( $self->SUPER::init( @_ ) );
35 }
36  
37 sub as_markdown
38 {
39 1 ▶ my $self = shift( @_ );
Subroutine as_markdown: called CC=1 SCAR=0.0
Pod documented
40 1 return( $self->raw->scalar );
41 }
42  
43 sub as_pod
44 {
45 0 ▶ my $self = shift( @_ );
Subroutine as_pod: not called CC=1 SCAR=6.9
Pod documented
46 # Hmmm, could be embedded within something else, so we cannot actually say that
47 # return( "=begin html\n\n" . $self->raw->scalar . "\n\n=end html\n" );
48 0 return( $self->raw->scalar );
49 }
50  
51 sub as_string
52 {
53 0 ▶ my $self = shift( @_ );
Subroutine as_string: not called CC=4 SCAR=30.0
Pod documented
54 0 my $html = $self->raw;
55 0 my $tree;
56 0 ▶ if( $html->length > 0 && ( $tree = $self->object ) )
Branch: 1 branch
BranchTrueFalseTotal
if ($html->length > 0 and $tree = $self->object) 0 0 0
Condition0%0/3
$html->length > 0 and $tree = $self->object
!ll&&!rl&&r
000
MC/DC0%0/2
$html->length > 0 and $tree = $self->object
$html->length > 0 $tree = $self->object
Truth table0%0/3
A and B
A= $html->length > 0B= $tree = $self->object
ABresult
0X0
100
111
57 {
58 0 my @elem = $tree->look_down( _tag => 'div', class => qr/\bmermaid\b/ );
59 0 ▶ if( scalar( @elem ) )
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @elem) 0 0 0
60 {
61 0 $self->document->setup_mermaid;
62 }
63 }
64 0 return( $html );
65 }
66  
67 0 ▶sub is_comment { return( shift->_set_get_boolean( 'is_comment', @_ ) ); }
Subroutine is_comment: not called CC=1 SCAR=6.9
Pod documented
68  
69 sub object
70 {
71 1 ▶ my $self = shift( @_ );
Subroutine object: called CC=3 SCAR=14.2
Pod documented
72 1 my $obj = $self->_set_get_object( 'object' );
73 1 ▶ return( $obj ) if( $obj );
Branch: 1 branch
BranchTrueFalseTotal
if $obj 0 1 1
74 1 ▶ return if( !$self->raw->length );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->raw->length 1 0 1
75 0 my $html = $self->raw->scalar;
76 0 $obj = $self->parse_html( $html );
77 0 $self->_set_get_object( 'object', 'HTML::Object::Element', $obj );
78 0 return( $obj );
79 }
80  
81 2 1;
82 # NOTE: POD
83 __END__
« lib/Markdown/Parser/Abbr.pm ↑ Summary blib/lib/Markdown/Parser/HTML.pm »