| 1 | ##---------------------------------------------------------------------------- | ||||||||||
| 2 | ## Markdown Parser Only - ~/lib/Markdown/Parser/NewLine.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::NewLine; | ||||||||||
| 14 | BEGIN | ||||||||||
| 15 | 1 | ▶ | { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 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 | our $VERSION = 'v0.3.0'; | |||||||||
| 21 | }; | ||||||||||
| 22 | |||||||||||
| 23 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 24 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 25 | |||||||||||
| 26 | sub init | ||||||||||
| 27 | 0 | ▶ | { | ||||||||
|
Subroutine
init: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 28 | 0 | my $self = shift( @_ ); | |||||||||
| 29 | # Some new lines are silents, and some are explicit like following a <br /> | ||||||||||
| 30 | 0 | $self->{break} = 0; | |||||||||
| 31 | 0 | $self->{new_line} = "\n"; | |||||||||
| 32 | 0 | $self->{tag_name} = 'nl'; | |||||||||
| 33 | # Repeating counts the number of occurence of new lines without having multiple new line objects | ||||||||||
| 34 | 0 | $self->{repeating} = 1; | |||||||||
| 35 | 0 | return( $self->SUPER::init( @_ ) ); | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | sub as_markdown | ||||||||||
| 39 | 0 | ▶ | { | ||||||||
|
Subroutine
as_markdown: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 40 | 0 | my $self = shift( @_ ); | |||||||||
| 41 | 0 | my $arr = $self->new_array; | |||||||||
| 42 | 0 | $arr->push( $self->new_line->scalar ); | |||||||||
| 43 | 0 | return( $arr->join( '' )->scalar ); | |||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | sub as_pod | ||||||||||
| 47 | 0 | ▶ | { | ||||||||
|
Subroutine
as_pod: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 48 | 0 | my $self = shift( @_ ); | |||||||||
| 49 | 0 | my $arr = $self->new_array; | |||||||||
| 50 | 0 | $arr->push( $self->new_line->scalar ); | |||||||||
| 51 | 0 | return( $arr->join( '' )->scalar ); | |||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | sub as_string | ||||||||||
| 55 | 0 | ▶ | { | ||||||||
|
Subroutine
as_string: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 56 | 0 | my $self = shift( @_ ); | |||||||||
| 57 | 0 | my $arr = $self->new_array; | |||||||||
| 58 | 0 | ▶ | $arr->push( '<br />' ) if( $self->break ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 59 | 0 | $arr->push( $self->new_line->scalar ); | |||||||||
| 60 | 0 | return( $arr->join( '' )->scalar ); | |||||||||
| 61 | } | ||||||||||
| 62 | |||||||||||
| 63 | 0 | ▶ | sub break { return( shift->_set_get_boolean( 'break', @_ ) ); } | ||||||||
|
Subroutine
break: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 64 | |||||||||||
| 65 | 0 | ▶ | sub new_line { return( shift->_set_get_scalar_as_object( 'new_line', @_ ) ); } | ||||||||
|
Subroutine
new_line: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 66 | |||||||||||
| 67 | 0 | ▶ | sub repeating : lvalue | ||||||||
|
Subroutine
repeating: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 68 | { | ||||||||||
| 69 | 0 | my $self = shift( @_ ); | |||||||||
| 70 | 0 | my $v = $self->{repeating}; | |||||||||
| 71 | 0 | my $v2 = $self->_set_get_lvalue( 'repeating', @_ ); | |||||||||
| 72 | 0 | ▶ | if( $v != $v2 ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 73 | { | ||||||||||
| 74 | 0 | $self->tag_name( 'nl' . $v2 ); | |||||||||
| 75 | } | ||||||||||
| 76 | 0 | return( $v2 ); | |||||||||
| 77 | } | ||||||||||
| 78 | |||||||||||
| 79 | 1 | 1; | |||||||||
| 80 | # NOTE: POD | ||||||||||
| 81 | __END__ | ||||||||||