issue 668, htmlmin.py, thanks kerncece

This commit is contained in:
Massimo DiPierro
2012-02-21 14:04:01 -06:00
parent 5316998975
commit b3702a3bfd
2 changed files with 14 additions and 1 deletions
+1 -1
View File
@@ -1 +1 @@
Version 1.99.4 (2012-02-21 00:06:19) stable
Version 1.99.4 (2012-02-21 14:03:59) stable
+13
View File
@@ -0,0 +1,13 @@
# coding: utf-8
import re
def minify(response):
def _replace(match):
match = match.group()
# save whole <pre>, <textarea> tags, and opening <!-- (so it doesn't break <script>)
# otherwise, replace all whitespace with a single space character
return match if match.startswith(('<pre', '<textarea', '<!--')) else ' '
cpat = re.compile(r'\s+|<pre(.*?)</pre>|<textarea(.*?)</textarea>|<!--\s', re.DOTALL)
return cpat.sub(_replace, response)