<s> """<STR_LIT>""" <EOL> import re <EOL> import markdown <EOL> from markdown . util import etree <EOL> class DefListProcessor ( markdown . blockprocessors . BlockProcessor ) : <EOL> """<STR_LIT>""" <EOL> RE = re . compile ( r'<STR_LIT>' ) <EOL> NO_INDENT_RE = re . compile ( r'<STR_LIT>' ) <EOL> def test ( self , parent , block ) : <EOL> return bool ( self . RE . search ( block ) ) <EOL> def run ( self , parent , blocks ) : <EOL> block = blocks . pop ( <NUM_LIT:0> ) <EOL> m = self . RE . search ( block ) <EOL> terms = [ l . strip ( ) for l in block [ : m . start ( ) ] . split ( '<STR_LIT:\n>' ) if l . strip ( ) ] <EOL> block = block [ m . end ( ) : ] <EOL> no_indent = self . NO_INDENT_RE . match ( block ) <EOL> if no_indent : <EOL> d , theRest = ( block , None ) <EOL> else : <EOL> d , theRest = self . detab ( block ) <EOL> if d : <EOL> d = '<STR_LIT>' % ( m . group ( <NUM_LIT:2> ) , d ) <EOL> else : <EOL> d = m . group ( <NUM_LIT:2> ) <EOL> sibling = self . lastChild ( parent ) <EOL> if not terms and sibling . tag == '<STR_LIT:p>' : <EOL> state = '<STR_LIT>' <EOL> terms = sibling . text . split ( '<STR_LIT:\n>' ) <EOL> parent . remove ( sibling ) <EOL> sibling = self . lastChild ( parent ) <EOL> else : <EOL> state = '<STR_LIT:list>' <EOL> if sibling and sibling . tag == '<STR_LIT>' : <EOL> dl = sibling <EOL> if len ( dl ) and dl [ - <NUM_LIT:1> ] . tag == '<STR_LIT>' and len ( dl [ - <NUM_LIT:1> ] ) : <EOL> state = '<STR_LIT>' <EOL> else : <EOL> dl = etree . SubElement ( parent , '<STR_LIT>' ) <EOL> for term in terms : <EOL> dt = etree . SubElement ( dl , '<STR_LIT>' ) <EOL> dt . text = term <EOL> self . parser . state . set ( state ) <EOL> dd = etree . SubElement ( dl , '<STR_LIT>' ) <EOL> self . parser . parseBlocks ( dd , [ d ] ) <EOL> self . parser . state . reset ( ) <EOL> if theRest : <EOL> blocks . insert ( <NUM_LIT:0> , theRest ) <EOL> class DefListIndentProcessor ( markdown . blockprocessors . ListIndentProcessor ) : <EOL> """<STR_LIT>""" <EOL> ITEM_TYPES = [ '<STR_LIT>' ] <EOL> LIST_TYPES = [ '<STR_LIT>' ] <EOL> def create_item ( self , parent , block ) : <EOL> """<STR_LIT>""" <EOL> dd = markdown . etree . SubElement ( parent , '<STR_LIT>' ) <EOL> self . parser . parseBlocks ( dd , [ block ] ) <EOL> class DefListExtension ( markdown . Extension ) : <EOL> """<STR_LIT>""" <EOL> def extendMarkdown ( self , md , md_globals ) : <EOL> """<STR_LIT>""" <EOL> md . parser . blockprocessors . add ( '<STR_LIT>' , <EOL> DefListIndentProcessor ( md . parser ) , <EOL> '<STR_LIT>' ) <EOL> md . parser . blockprocessors . add ( '<STR_LIT>' , <EOL> DefListProcessor ( md . parser ) , <EOL> '<STR_LIT>' ) <EOL> def makeExtension ( configs = { } ) : <EOL> return DefListExtension ( configs = configs ) </s>
