Parser/HTML.pm

filter: Statementstmt 67.3% 31 / 46 Branchbran 25.0% 2 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 76.9% 10 / 13 Podpod 100% 6 / 6 totaltotal 62.8% 49 / 78 CC 6 SCAR 17.7
CC
6
Cov
58%
as_string
20.0
object
4.1
as_pod
2.0
CRAP 5.9
« Parser/Abbr.pm ↑ Summary Parser/Footnote.pm »
1 ##----------------------------------------------------------------------------
2 ## Markdown Parser Only - ~/lib/Markdown/Parser/HTML.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::HTML;
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->{is_comment} = 0;
30 # HTML::Object::Element object
31 1 $self->{object} = '';
32 1 $self->{tag_name} = 'html';
33 1 return( $self->SUPER::init( @_ ) );
34 }
35  
36 sub as_markdown
37 1 ▶{
Subroutine as_markdown: called CC=1 SCAR=0.0
Pod documented
38 1 my $self = shift( @_ );
39 1 return( $self->raw->scalar );
40 }
41  
42 sub as_pod
43 0 ▶{
Subroutine as_pod: not called CC=1 SCAR=6.9
Pod documented
44 0 my $self = shift( @_ );
45 # Hmmm, could be embedded within something else, so we cannot actually say that
46 # return( "=begin html\n\n" . $self->raw->scalar . "\n\n=end html\n" );
47 0 return( $self->raw->scalar );
48 }
49  
50 sub as_string
51 0 ▶{
Subroutine as_string: not called CC=4 SCAR=30.0
Pod documented
52 0 my $self = shift( @_ );
53 0 my $html = $self->raw;
54 0 my $tree;
55 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
56 {
57 0 my @elem = $tree->look_down( _tag => 'div', class => qr/\bmermaid\b/ );
58 0 ▶ if( scalar( @elem ) )
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @elem) 0 0 0
59 {
60 0 $self->document->setup_mermaid;
61 }
62 }
63 0 return( $html );
64 }
65  
66 0 ▶sub is_comment { return( shift->_set_get_boolean( 'is_comment', @_ ) ); }
Subroutine is_comment: not called CC=1 SCAR=6.9
Pod documented
67  
68 sub object
69 1 ▶{
Subroutine object: called CC=3 SCAR=14.2
Pod documented
70 1 my $self = shift( @_ );
71 1 my $obj = $self->_set_get_object( 'object' );
72 1 ▶ return( $obj ) if( $obj );
Branch: 1 branch
BranchTrueFalseTotal
if $obj 0 1 1
73 1 ▶ return if( !$self->raw->length );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->raw->length 1 0 1
74 0 my $html = $self->raw->scalar;
75 0 $obj = $self->parse_html( $html );
76 0 $self->_set_get_object( 'object', 'HTML::Object::Element', $obj );
77 0 return( $obj );
78 }
79  
80 2 1;
81 # NOTE: POD
82 __END__
« Parser/Abbr.pm ↑ Summary Parser/Footnote.pm »