lib/Markdown/Parser/NewLine.pm

filter: Statementstmt 86.6% 13 / 15 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 90.0% 18 / 20 CC 1 SCAR 0.6
CC
1
Cov
87%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« lib/Markdown/Parser/Text.pm ↑ Summary
1 ##----------------------------------------------------------------------------
2 ## Markdown Parser Only - ~/lib/Markdown/Parser/NewLine.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/10/11
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::NewLine;
14 BEGIN
15 {
16 1 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶ use parent qw( Markdown::Parser::Element );
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶ use vars qw( $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶ use Want;
Subroutine BEGIN: called CC=1 SCAR=2.6
21 use Devel::Confess;
22 our $VERSION = 'v0.2.1';
23 };
24  
25 use strict;
26 use warnings;
27  
28 sub init
29 {
30 my $self = shift( @_ );
31 # Some new lines are silents, and some are explicit like following a <br />
32 $self->{break} = 0;
33 $self->{new_line} = "\n";
34 $self->{tag_name} = 'nl';
35 # Repeating counts the number of occurence of new lines without having multiple new line objects
36 $self->{repeating} = 1;
37 return( $self->SUPER::init( @_ ) );
38 }
39  
40 sub as_markdown
41 {
42 my $self = shift( @_ );
43 my $arr = $self->new_array;
44 $arr->push( $self->new_line->scalar );
45 return( $arr->join( '' )->scalar );
46 }
47  
48 sub as_pod
49 {
50 my $self = shift( @_ );
51 my $arr = $self->new_array;
52 $arr->push( $self->new_line->scalar );
53 return( $arr->join( '' )->scalar );
54 }
55  
56 sub as_string
57 {
58 my $self = shift( @_ );
59 my $arr = $self->new_array;
60 $arr->push( '<br />' ) if( $self->break );
61 $arr->push( $self->new_line->scalar );
62 return( $arr->join( '' )->scalar );
63 }
64  
65 sub break { return( shift->_set_get_boolean( 'break', @_ ) ); }
66  
67 sub new_line { return( shift->_set_get_scalar_as_object( 'new_line', @_ ) ); }
68  
69 sub repeating : lvalue
70 {
71 my $self = shift( @_ );
72 my $v = $self->{repeating};
73 my $v2 = $self->_set_get_lvalue( 'repeating', @_ );
74 if( $v != $v2 )
75 {
76 $self->tag_name( 'nl' . $v2 );
77 }
78 return( $v2 );
79 }
80  
81 1;
82 # NOTE: POD
83 __END__
« lib/Markdown/Parser/Text.pm ↑ Summary