Package tdi :: Package tools :: Module html :: Class MinifyFilter
[frames] | no frames]

Class MinifyFilter

source code

             object --+    
                      |    
filters.BaseEventFilter --+
                          |
                         MinifyFilter

Strip unneeded whitespace and comments
Instance Methods
 
__init__(self, builder, comment_filter=None)
Initialization
source code
 
finalize(self)
Flush the last chunk
source code
 
handle_text(self, data)
Buffer the text
source code
 
handle_starttag(self, name, attr, closed, data) source code
 
handle_endtag(self, name, data) source code
 
handle_comment(self, data) source code
 
handle_msection(self, name, value, data) source code
 
handle_decl(self, name, value, data) source code
 
handle_pi(self, data) source code

Inherited from filters.BaseEventFilter: __getattr__

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Instance Variables

Inherited from filters.BaseEventFilter: builder

Properties

Inherited from object: __class__

Method Details

__init__(self, builder, comment_filter=None)
(Constructor)

source code 
Initialization
Parameters:
  • builder (BuildingListenerInterface) - Next level builder.
  • comment_filter (callable) - Comment filter. A function which takes the comment data and returns a filtered comment (which is passed through to the builder) or None (meaning the comment can be stripped completely). For example:

    def keep_ad_comments(data):
        if 'google_ad_section' in data:
            return data
        return None
    

    If omitted or None, all comments are stripped.

Overrides: object.__init__

finalize(self)

source code 
Flush the last chunk

handle_text(self, data)

source code 
Buffer the text

handle_starttag(self, name, attr, closed, data)

source code 

handle_endtag(self, name, data)

source code 

handle_comment(self, data)

source code 

handle_msection(self, name, value, data)

source code 

handle_decl(self, name, value, data)

source code 

handle_pi(self, data)

source code