<s> """<STR_LIT>""" <EOL> import markdown <EOL> try : <EOL> import tidy <EOL> except ImportError : <EOL> tidy = None <EOL> class TidyExtension ( markdown . Extension ) : <EOL> def __init__ ( self , configs ) : <EOL> self . config = dict ( output_xhtml = <NUM_LIT:1> , <EOL> show_body_only = <NUM_LIT:1> , <EOL> char_encoding = '<STR_LIT:utf8>' <EOL> ) <EOL> for c in configs : <EOL> self . config [ c [ <NUM_LIT:0> ] ] = c [ <NUM_LIT:1> ] <EOL> def extendMarkdown ( self , md , md_globals ) : <EOL> md . tidy_options = self . config <EOL> if tidy : <EOL> md . postprocessors [ '<STR_LIT>' ] = TidyProcessor ( md ) <EOL> class TidyProcessor ( markdown . postprocessors . Postprocessor ) : <EOL> def run ( self , text ) : <EOL> enc = self . markdown . tidy_options . get ( '<STR_LIT>' , '<STR_LIT:utf8>' ) <EOL> return unicode ( tidy . parseString ( text . encode ( enc ) , <EOL> ** self . markdown . tidy_options ) , <EOL> encoding = enc ) <EOL> def makeExtension ( configs = None ) : <EOL> return TidyExtension ( configs = configs ) </s>
