<s> import os <EOL> import re <EOL> import HTMLParser <EOL> __all__ = [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> parser = HTMLParser . HTMLParser ( ) <EOL> nlbr_pattern = re . compile ( r'<STR_LIT>' ) <EOL> quot_pattern = re . compile ( r'<STR_LIT>' ) <EOL> code_pattern = re . compile ( r'<STR_LIT>' ) <EOL> html_pattern = re . compile ( r'<STR_LIT>' ) <EOL> def get_first_group ( match ) : <EOL> """<STR_LIT>""" <EOL> return match . group ( <NUM_LIT:1> ) <EOL> def replace_newlines ( s ) : <EOL> """<STR_LIT>""" <EOL> return nlbr_pattern . sub ( os . linesep , s ) <EOL> def preserve_quotes ( s ) : <EOL> """<STR_LIT>""" <EOL> return quot_pattern . sub ( get_first_group , s ) <EOL> def preserve_code ( s ) : <EOL> """<STR_LIT>""" <EOL> return code_pattern . sub ( get_first_group , s ) <EOL> def remove_meta ( s ) : <EOL> """<STR_LIT>""" <EOL> return html_pattern . sub ( '<STR_LIT>' , s ) <EOL> def unescape ( s ) : <EOL> """<STR_LIT>""" <EOL> return parser . unescape ( s ) <EOL> def sanitize ( s ) : <EOL> """<STR_LIT>""" <EOL> s = preserve_quotes ( s ) <EOL> s = preserve_code ( s ) <EOL> s = replace_newlines ( s ) <EOL> s = remove_meta ( s ) <EOL> return unescape ( s ) </s>
