from BeautifulSoup import BeautifulSoup

class Prettify(object):
    def process_response(self, request, response):
        if response.has_header('Content-Type') and response['Content-Type'].startswith('text/html'):
            response.content = BeautifulSoup(response.content).prettify()
        
        return response