source: OpenRLabs-Git/deploy/rlabs-docker/web2py-rlabs/gluon/contrib/minify/htmlmin.py

main
Last change on this file was 42bd667, checked in by David Fuertes <dfuertes@…>, 4 years ago

Historial Limpio

  • Property mode set to 100755
File size: 494 bytes
Line 
1# coding: utf-8
2
3import re
4
5
6def minify(response):
7    def _replace(match):
8        match = match.group()
9        # save whole <pre>, <textarea> tags, and opening <!-- (so it doesn't break <script>)
10        # otherwise, replace all whitespace with a single space character
11        return match if match.startswith(('<pre', '<textarea', '<!--')) else ' '
12
13    cpat = re.compile(
14        r'\s+|<pre(.*?)</pre>|<textarea(.*?)</textarea>|<!--\s', re.DOTALL)
15    return cpat.sub(_replace, response)
Note: See TracBrowser for help on using the repository browser.