HTML::...ration(3pm)

πŸ“¦
version 3.16 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking

HTML::TokeParser::Simple::Token::Declaration πŸ’–

ok so bestie, this is a page from the User Contributed Perl Documentation manual, and it's all about HTML::TokeParser::Simple::Token::Declaration β€” the token class that handles declarations. yes, like that one. the DTD one. πŸŽ€


✨ NAME ✨

HTML::TokeParser::Simple::Token::Declaration β€” it's the Token.pm declaration class, periodt. πŸ’…


✨ SYNOPSIS ✨

ok here's the vibe, copy this exactly bestie, no cap:

use HTML::TokeParser::Simple;
my $p = HTML::TokeParser::Simple->new( $somefile );

while ( my $token = $p->get_token ) {
    # This prints all text in an HTML doc (i.e., it strips the HTML)
    next unless $token->is_text;
    print $token->as_is;
}

see that comment in there? yeah β€” that loop prints all the text in an HTML doc, which is a fancy way of saying it strips the HTML right out. iconic behavior honestly. πŸ¦‹


✨ DESCRIPTION ✨

This is the declaration class for tokens. that's the whole thing. she's a specialist, she does declarations, and she does them well. πŸ‘‘


✨ OVERRIDDEN METHODS ✨

these are the methods that got a lil glow-up specifically for this class, so listen up:

is_declaration πŸ’«

is_declaration() will return true if the token is the DTD at the top of the HTML. yes, the DTD β€” that <!DOCTYPE ...> situation sitting at the very top of the file like it owns the place. if that's your token, this method says yes. no notes. πŸ”₯

lowkey important: it's checking for the DTD specifically at the top of the HTML. don't go assuming it blesses every declaration you throw at it, bestie. πŸ™ˆ

and that's the whole page!! short, sweet, very main character energy. 🧚

this lil doc came from perl v5.32.1 and was dated 2021-12-05 β€” so yeah, it's giving vintage but still slaying. πŸ’– byeee, go parse some HTML. 🌸✨

πŸ“¦ where this page comes from