File: clean-and-pre_282503.patch

package info (click to toggle)
libhtml-clean-perl 0.8-12
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 424 kB
  • ctags: 131
  • sloc: perl: 443; makefile: 2
file content (37 lines) | stat: -rw-r--r-- 1,123 bytes parent folder | download
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
--- a/lib/HTML/Clean.pm
+++ b/lib/HTML/Clean.pm
@@ -366,6 +366,16 @@ The following options are recognized:
 
 =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 @@ sub strip {
   }
 
   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