A workaround that needs more work (the test fails )

diff -ruN HTML-HTML5-ToText-0.002/lib/HTML/HTML5/ToText.pm HTML-HTML5- +ToText-0.00201/lib/HTML/HTML5/ToText.pm --- HTML-HTML5-ToText-0.002/lib/HTML/HTML5/ToText.pm 2012-01-31 01: +41:12.000000000 -0800 +++ HTML-HTML5-ToText-0.00201/lib/HTML/HTML5/ToText.pm 2013-04-16 2 +2:08:08.296875000 -0700 @@ -126,7 +126,10 @@ else { my $elem = uc $kid->nodeName; - my $str = $self->$elem($kid, %args); + $elem =~ s/[^A-Z_0-9]//g; + local $@; + my $str = eval { $self->$elem($kid, %args) }; + $@ and next ; if ($str =~ m{^\n} and not $kid->previousSibling) { diff -ruN HTML-HTML5-ToText-0.002/MANIFEST HTML-HTML5-ToText-0.00201/M +ANIFEST --- HTML-HTML5-ToText-0.002/MANIFEST 2012-01-31 01:44:50.000000000 +-0800 +++ HTML-HTML5-ToText-0.00201/MANIFEST 2013-04-16 22:17:30.12500000 +0 -0700 @@ -47,4 +47,5 @@ t/01basic.t t/02simple.t t/03tables.t +t/04comment.t SIGNATURE Public-key signature (added +by MakeMaker) diff -ruN HTML-HTML5-ToText-0.002/t/04comment.t HTML-HTML5-ToText-0.00 +201/t/04comment.t --- HTML-HTML5-ToText-0.002/t/04comment.t 1969-12-31 16:00:00.00000 +0000 -0800 +++ HTML-HTML5-ToText-0.00201/t/04comment.t 2013-04-16 22:19:34.828 +125000 -0700 @@ -0,0 +1,26 @@ +use Test::More tests => 1; +use HTML::HTML5::Parser; +use HTML::HTML5::ToText; + +my $dom = HTML::HTML5::Parser->load_html(IO => \*DATA); +my $str = HTML::HTML5::ToText->with_traits(qw/TextFormatting ShowLink +s ShowImages/)->process($dom); + +my $output = <<'OUTPUT'; +Foo +LINK: <style.css> (stylesheet) + +*Hello world <http://example.com>* + +_how_are +[IMG:_you]?_ +OUTPUT + +#~ use Data::Dump qw/ dd pp /; warn pp([ $str, $output] ); +is $str, $output; + +__DATA__ +<!doctype html> +<title>Foo</title> +<link rel=stylesheet href=style.css> +<!-- a comment here --><p><!-- a comment here --><b><!-- a comment he +re -->Hello <a href="http://example.com">world</a></b><!-- a comment +here --></p> +<!-- a comment here --><p><!-- a comment here --><i>how are<br><img s +rc=you.jpeg alt=you>?</i><!-- a comment here --></p>

In reply to Re: Can't locate object method "#COMMENT" via package "MooseX::Traits::__ANON__::SERIAL::1" at HTML/HTML5/ToText.pm line 129, <STDIN> line 3016. by Anonymous Monk
in thread Can't locate object method "#COMMENT" via package "MooseX::Traits::__ANON__::SERIAL::1" at HTML/HTML5/ToText.pm line 129, <STDIN> line 3016. by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.