From: David Dorward Date: Wed, 21 Dec 2011 18:07:54 +0000 (+0000) Subject: Add tests for parsing sections of HTML defined as containing CDATA. X-Git-Tag: release_0.009007_1~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FHTML-Zoom.git;a=commitdiff_plain;h=b0ed28590e66eac5f5cb294a650c6d8faff00dd5 Add tests for parsing sections of HTML defined as containing CDATA. --- diff --git a/lib/HTML/Zoom.pm b/lib/HTML/Zoom.pm index df4d3a0..053f458 100644 --- a/lib/HTML/Zoom.pm +++ b/lib/HTML/Zoom.pm @@ -778,6 +778,8 @@ John Napiorkowski Robert Buels +David Dorward + =head1 COPYRIGHT Copyright (c) 2010-2011 the HTML::Zoom L and L diff --git a/t/parse_cdata.t b/t/parse_cdata.t new file mode 100644 index 0000000..81e95fe --- /dev/null +++ b/t/parse_cdata.t @@ -0,0 +1,97 @@ +use strictures 1; +use HTML::Zoom; +use Test::More ;# skip_all => "Totally doesn't work yet"; + +# Test that contant of elements defined as containing intrinsic CDATA are not +# selected as elements + +# NB: This tests HTML parsing rules. XHTML is different. + +my $template = < + + + Test + + + +

Unmodified

+ + +HTML + +my $expected_p = < + + + Test + + + +

Unmodified

+ + +HTML + +my $expected_t = < + + + Test + + + +

Unmodified

+ + +HTML + +my $replaced_p = HTML::Zoom->from_html($template)->select('p')->replace_content('Replaced')->to_html; +is($replaced_p, $expected_p, "Script element parsed as CDATA"); + +my $replaced_t = HTML::Zoom->from_html($template)->select('textarea')->replace_content('Replaced')->to_html; +is($replaced_t, $expected_t, "Style element parsed as CDATA"); + +done_testing;