| 1 | ##---------------------------------------------------------------------------- | ||
| 2 | ## HTML Object - ~/lib/HTML/Object/Declaration.pm | ||
| 3 | ## Version v0.2.0 | ||
| 4 | ## Copyright(c) 2021 DEGUEST Pte. Ltd. | ||
| 5 | ## Author: Jacques Deguest <jack@deguest.jp> | ||
| 6 | ## Created 2021/04/19 | ||
| 7 | ## Modified 2022/09/18 | ||
| 8 | ## All rights reserved. | ||
| 9 | ## | ||
| 10 | ## | ||
| 11 | ## This program is free software; you can redistribute it and/or modify it | ||
| 12 | ## under the same terms as Perl itself. | ||
| 13 | ##---------------------------------------------------------------------------- | ||
| 14 | package HTML::Object::Declaration; | ||
| 15 | BEGIN | ||
| 16 | { | ||
| 17 | use strict; | ||
| 18 | use warnings; | ||
| 19 | warnings::register_categories( 'HTML::Object' ); | ||
| 20 | use parent qw( HTML::Object::Element ); | ||
| 21 | use vars qw( $VERSION ); | ||
| 22 | our $VERSION = 'v0.2.0'; | ||
| 23 | }; | ||
| 24 | |||
| 25 | use strict; | ||
| 26 | use warnings; | ||
| 27 | |||
| 28 | sub init | ||
| 29 | { | ||
| 30 | my $self = shift( @_ ); | ||
| 31 | $self->{is_empty} = 1; | ||
| 32 | $self->{name} = 'html' unless( CORE::exists( $self->{name} ) && CORE::length( $self->{name} ) ); | ||
| 33 | $self->{_init_strict_use_sub} = 1; | ||
| 34 | $self->{_exception_class} = 'HTML::Object::Exception'; | ||
| 35 | $self->SUPER::init( @_ ) || return( $self->pass_error ); | ||
| 36 | $self->{tag} = '_declaration'; | ||
| 37 | return( $self ); | ||
| 38 | } | ||
| 39 | |||
| 40 | sub as_string | ||
| 41 | { | ||
| 42 | my $self = shift( @_ ); | ||
| 43 | if( !$self->original->is_empty ) | ||
| 44 | { | ||
| 45 | return( $self->original ); | ||
| 46 | } | ||
| 47 | else | ||
| 48 | { | ||
| 49 | my $name = $self->name; | ||
| 50 | return( $self->new_scalar( "<!DOCTYPE" . ( ( defined( $name ) && CORE::length( "$name" ) ) ? " ${name}" : '' ) . '>' ) ); | ||
| 51 | } | ||
| 52 | } | ||
| 53 | |||
| 54 | sub as_xml { return( shift->as_string( @_ ) ); } | ||
| 55 | |||
| 56 | sub checksum { return( '' ); } | ||
| 57 | |||
| 58 | sub name | ||
| 59 | { | ||
| 60 | my $self = shift( @_ ); | ||
| 61 | if( my $rv = $self->original->match( qr/^<!DOCTYPE[[:blank:]\h]+(\w+)/ ) ) | ||
| 62 | { | ||
| 63 | return( lc( $rv->capture->first ) ); | ||
| 64 | } | ||
| 65 | return( '' ); | ||
| 66 | } | ||
| 67 | |||
| 68 | sub set_checksum {} | ||
| 69 | |||
| 70 | 1; | ||
| 71 | # NOTE: POD | ||
| 72 | __END__ |