1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
Index: libhtml-clean-perl/lib/HTML/Clean.pm
===================================================================
--- libhtml-clean-perl.orig/lib/HTML/Clean.pm 2008-03-07 10:48:37.000000000 +0200
+++ libhtml-clean-perl/lib/HTML/Clean.pm 2008-03-07 10:52:18.000000000 +0200
@@ -366,6 +366,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/
@@ -426,6 +436,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
|