| 1 | ##---------------------------------------------------------------------------- | ||||||||||
| 2 | ## Markdown Parser Only - ~/lib/Markdown/Parser/TableCaption.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::TableCaption; | ||||||||||
| 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 | 0 | $self->{position} = 'top'; | |||||||||
| 30 | 0 | $self->{tag_name} = 'caption'; | |||||||||
| 31 | 0 | return( $self->SUPER::init( @_ ) ); | |||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | sub as_markdown | ||||||||||
| 35 | 0 | ▶ | { | ||||||||
|
Subroutine
as_markdown: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 36 | 0 | my $self = shift( @_ ); | |||||||||
| 37 | 0 | ▶ | return( $self->{_as_markdown} ) if( $self->{_as_markdown} ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | 0 | ▶ | $self->{_as_markdown} = sprintf( ' [%s]', $self->children->map(sub{ $_->as_markdown })->join( '' )->scalar ); | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 39 | 0 | return( $self->{_as_markdown} ); | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | sub as_pod | ||||||||||
| 43 | 0 | ▶ | { | ||||||||
|
Subroutine
as_pod: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 44 | 0 | my $self = shift( @_ ); | |||||||||
| 45 | 0 | ▶ | return( $self->{_as_pod} ) if( $self->{_as_pod} ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | 0 | ▶ | $self->{_as_pod} = sprintf( ' [%s]', $self->children->map(sub{ $_->as_pod })->join( '' )->scalar ); | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 47 | 0 | return( $self->{_as_pod} ); | |||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | sub as_string | ||||||||||
| 51 | 0 | ▶ | { | ||||||||
|
Subroutine
as_string: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||
| 52 | 0 | my $self = shift( @_ ); | |||||||||
| 53 | 0 | my $tag = $self->tag_name; | |||||||||
| 54 | 0 | my $tag_open = $tag; | |||||||||
| 55 | 0 | my $arr = $self->new_array; | |||||||||
| 56 | 0 | $arr->push( "<$tag_open" ); | |||||||||
| 57 | 0 | my $attr = $self->new_array; | |||||||||
| 58 | 0 | ▶ | $attr->push( $self->format_id ) if( $self->id->length ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 59 | 0 | ▶ | $attr->push( $self->format_class ) if( $self->class->length ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 60 | 0 | my $attributes = $self->format_attributes; | |||||||||
| 61 | 0 | ▶ | $attr->push( $attributes->join( ' ' )->scalar ) if( $attributes->length ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 62 | 0 | ▶ | $arr->push( ' ' . $attr->join( ' ' )->scalar ) if( $attr->length ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 63 | 0 | $arr->push( '>' ); | |||||||||
| 64 | 0 | ▶ | $arr->push( $self->children->map(sub{ $_->as_string })->join( "\n" )->scalar ); | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 65 | 0 | $arr->push( "</$tag>" ); | |||||||||
| 66 | 0 | return( $arr->join( '' )->scalar ); | |||||||||
| 67 | } | ||||||||||
| 68 | |||||||||||
| 69 | ## 'top' or 'bottom' of the table | ||||||||||
| 70 | 0 | ▶ | sub position { return( shift->_set_get_scalar_as_object( 'position', @_ ) ); } | ||||||||
|
Subroutine
position: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 71 | |||||||||||
| 72 | 1 | 1; | |||||||||
| 73 | # NOTE: POD | ||||||||||
| 74 | __END__ | ||||||||||