1 package SL::HTML::Util;
11 my ($class_or_value) = @_;
13 my $value = !ref($class_or_value) && (($class_or_value // '') eq 'SL::HTML::Util') ? $_[1] : $class_or_value;
16 %stripper = ( parser => HTML::Parser->new );
18 $stripper{parser}->handler(text => sub { $stripper{text} .= $_[1]; });
22 $stripper{parser}->parse($value);
23 $stripper{parser}->eof;
25 return delete $stripper{text};
37 SL::HTML::Util - Utility functions dealing with HTML
41 my $plain_text = SL::HTML::Util->strip('<h1>Hello World</h1>');
47 =item C<strip $html_content>
49 Removes all HTML elements and tags from C<$html_content> and returns
50 the remaining plain text.
60 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>