Test::HTML::Lint(3pm)

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

πŸ’– Test::HTML::Lint πŸ’–

okay bestie, so this is Test::HTML::Lint, a lil module from the User Contributed Perl Documentation corner of the universe, and it is exactly what it sounds like: a Test::More-style wrapper around HTML::Lint. no cap.

✨ NAME ✨

Test::HTML::Lint β€” a Test::More-style wrapper around HTML::Lint. that's it, that's the whole vibe πŸ¦‹

🌸 VERSION 🌸

Version 2.32 ✨

πŸŽ€ SYNOPSIS πŸŽ€

use Test::HTML::Lint tests => 4;

my $table = build_display_table();
html_ok( $table, 'Built display table properly' );

πŸ’… DESCRIPTION πŸ’…

So here's the tea: this module hands you a few convenience methods for testing exception-based code. it's built with Test::Builder, which means it plays happily with Test::More and all their friends 🫢

and if you're not already familiar with Test::More, bestie, now would be the time to go take a look. like, right now. go. πŸ‘€


πŸ‘‘ EXPORT πŸ‘‘

"html_ok"

πŸ’– html_ok( [$lint, ] $html, $name ) πŸ’–

This one checks to see if $html is a valid HTML document β€” and yes, that includes checking for the <html>, <head>, <title>> and <body> tags. (not a typo on my end, that double > is literally in there, iykyk πŸ™ˆ)

If what you're checking is only a fragment of an HTML document, use "html_fragment_ok()" instead. she's the one for that job.

If you pass an HTML::Lint object, "html_ok()" will use that for its settings. main character energy, your lint your rules:

my $lint = new HTML::Lint( only_types => STRUCTURE );
html_ok( $lint, $content, "Web page passes structural tests only" );

Otherwise, it will use the default rules. slay:

html_ok( $content, "Web page passes ALL tests" );
⚠️ Note that if you pass in your own HTML::Lint object, "html_ok()" will clear its errors before using it. so like, if you were attached to those errors… they're gone. πŸ’€

πŸ¦‹ html_fragment_ok( [$lint, ] $html, $name ) πŸ¦‹

Checks that $fragment is valid HTML, but not necessarily a valid HTML document. it's giving "good enough for a fragment" ✨

For example, this is a valid fragment, but not a valid HTML document:

<body>
    <p>Lorem ipsum</p>
</body>

because it doesn't contain <html> and <head> tags. so if you want to check that it is a valid document, use "html_ok()" instead. different test, different vibe.

If you pass an HTML::Lint object, "html_fragment_ok()" will use that for its settings:

my $lint = new HTML::Lint( only_types => STRUCTURE );
html_fragment_ok( $lint, $content, 'Web page passes structural tests only' );

Otherwise, it will use the default rules:

html_fragment_ok( $content, 'Fragment passes ALL tests' );
⚠️ Note that if you pass in your own HTML::Lint object, "html_fragment_ok()" will clear its errors before using it. same energy as above, still very much a thing. 🫢

😭 BUGS 😭

All bugs and requests are now being handled through GitHub. we're modern like that πŸ’…

https://github.com/petdance/html-lint/issues
🚨 DO NOT send bug reports to http://rt.cpan.org/. like, do not. i'm so serious.

🌈 TO DO 🌈

There needs to be a "html_table_ok()" to check that the HTML is a self-contained, well-formed table, and then a comparable one for "html_page_ok()". not me manifesting these into existence πŸ™

If you think this module should do something that it doesn't do at the moment, please let me know. bestie, the inbox is open πŸ’Œ

🧚 ACKNOWLEDGEMENTS 🧚

Thanks to chromatic and Michael G Schwern for the excellent Test::Builder, without which this module wouldn't be possible. absolute icons, both of them πŸ‘‘

Thanks to Adrian Howard for writing Test::Exception, from which most of this module is taken. king behaviour fr fr 🌟

Copyright 2005-2018 Andy Lester.

This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License v2.0.

http://www.opensource.org/licenses/Artistic-2.0
πŸ’œ Please note that these modules are not products of or supported by the employers of the various contributors to the code. just so we're clear!

⭐ AUTHOR ⭐

Andy Lester, "andy@petdance.com" ✨


and that's the whole page, babe! this lil doc ships with perl v5.32.0 and it's dated 2020-12-28 β€” the Test::HTML::Lint(3pm) manual, written by the lovely User Contributed Perl Documentation girlies. go lint something gorgeous πŸ’–πŸŽ€πŸ¦‹