The Perl and Raku Conference 2025: Greenville, South Carolina - June 27-29 Learn more

use Test::More tests => 1;
my $dom = HTML::HTML5::Parser->load_html(IO => \*DATA);
my $str = HTML::HTML5::ToText->with_traits(qw/TextFormatting ShowLinks ShowImages/)->process($dom);
is $str, <<'OUTPUT';
Foo
LINK: <style.css> (stylesheet)
*Hello world <http://enwp.org/Earth>*
_how_are
[IMG:_you]?_
OUTPUT
__DATA__
<!doctype html>
<title>Foo</title>
<link rel=stylesheet href=style.css>
<!-- comment -->
<p><b>Hello <a href="http://enwp.org/Earth">world</a></b></p>
<p><i>how are<br><img src=you.jpeg alt=you>?</i></p>