#NEWLINE# def clean( html , tags = None , attributes = None , styles = None ) : #NEWLINE# #INDENT# if ( tags is None ) : #NEWLINE# #INDENT# tags = ALLOWED_TAGS #NEWLINE# #UNINDENT# if ( attributes is None ) : #NEWLINE# #INDENT# attributes = ALLOWED_ATTRIBUTES #NEWLINE# #UNINDENT# if ( styles is None ) : #NEWLINE# #INDENT# styles = ALLOWED_STYLES #NEWLINE# #UNINDENT# def nofollow( attrs , new = False ) : #NEWLINE# #INDENT# if attrs [ 'href' ] . startswith ( 'mailto:' ) : #NEWLINE# #INDENT# return attrs #NEWLINE# #UNINDENT# attrs [ 'rel' ] = 'nofollow' #NEWLINE# return attrs #NEWLINE# #UNINDENT# cleaned = bleach . clean ( html , tags = tags , attributes = attributes , styles = styles ) #NEWLINE# cleaned = bleach . linkify ( cleaned , callbacks = [ ( lambda attrs , new : ( attrs if ( not new ) else None ) ) , nofollow ] , skip_pre = True , parse_email = False ) #NEWLINE# return cleaned