r1172 - in packages/libhtml-clean-perl/trunk: debian lib/HTML

Gunnar Wolf gwolf@costa.debian.org
Wed, 15 Jun 2005 15:23:28 +0000


Author: gwolf
Date: 2005-06-15 15:23:27 +0000 (Wed, 15 Jun 2005)
New Revision: 1172

Modified:
   packages/libhtml-clean-perl/trunk/debian/changelog
   packages/libhtml-clean-perl/trunk/lib/HTML/Clean.pm
Log:
Added documentation (and a warning) explaining why HTML::Clean does not properly
handle preformatted areas


Modified: packages/libhtml-clean-perl/trunk/debian/changelog
===================================================================
--- packages/libhtml-clean-perl/trunk/debian/changelog	2005-06-15 14:30:20 UTC (rev 1171)
+++ packages/libhtml-clean-perl/trunk/debian/changelog	2005-06-15 15:23:27 UTC (rev 1172)
@@ -1,3 +1,10 @@
+libhtml-clean-perl (0.8-8) unstable; urgency=low
+
+  * Added documentation (and a warning) explaining why HTML::Clean does
+    not properly handle preformatted areas (Closes: #282503)
+
+ -- Gunnar Wolf <gwolf@debian.org>  Wed, 15 Jun 2005 10:21:58 -0500
+
 libhtml-clean-perl (0.8-7) unstable; urgency=low
 
   * Fixed double comment tag at end of javascript (Closes: #303619)

Modified: packages/libhtml-clean-perl/trunk/lib/HTML/Clean.pm
===================================================================
--- packages/libhtml-clean-perl/trunk/lib/HTML/Clean.pm	2005-06-15 14:30:20 UTC (rev 1171)
+++ packages/libhtml-clean-perl/trunk/lib/HTML/Clean.pm	2005-06-15 15:23:27 UTC (rev 1172)
@@ -375,6 +375,16 @@
 
 =back
 
+Please note that if your HTML includes preformatted regions (this means, if
+it includes <pre>...</pre>, we do not suggest removing whitespace, as it will
+alter the rendered defaults. 
+
+HTML::Clean will print out a warning if it finds a preformatted region and is 
+requested to strip whitespace. In order to prevent this, specify that you don't
+want to strip whitespace - i.e.
+
+  $h->strip( {whitespace => 0} );
+
 =cut
 
 use vars qw/
@@ -435,6 +445,17 @@
   }
 
   if ($do_whitespace) {
+    if ($$h =~ /<pre/i) {
+	warn << 'EOF'
+Warning: Stripping whitespace will affect preformatted region\'s layout
+You have a <pre> region in your HTML, which depends on the whitespace not
+being modified. You requested to strip the whitespace - The rendered results
+will be affected.
+
+Hint: Use $h->strip({whitespace => 0}); instead.
+EOF
+    }
+
     $$h =~ s,[\r\n]+,\n,sg; # Carriage/LF -> LF
     $$h =~ s,\s+\n,\n,sg;   # empty line
     $$h =~ s,\n\s+<,\n<,sg; # space before tag