HTML::...ration(3pm)
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
- debian bookworm: libhtml-tokeparser-simple-perl 3.16-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libhtml-tokeparser-simple-perl 3.16-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libhtml-tokeparser-simple-perl 3.16-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libhtml-tokeparser-simple-perl 3.16-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libhtml-tokeparser-simple-perl 3.16-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libhtml-tokeparser-simple-perl 3.16-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms