<s> """<STR_LIT>""" <EOL> import __init__ as markdown , re <EOL> META_RE = re . compile ( r'<STR_LIT>' ) <EOL> META_MORE_RE = re . compile ( r'<STR_LIT>' ) <EOL> class MetaExtension ( markdown . Extension ) : <EOL> """<STR_LIT>""" <EOL> def extendMarkdown ( self , md , md_globals ) : <EOL> """<STR_LIT>""" <EOL> md . preprocessors . add ( "<STR_LIT>" , MetaPreprocessor ( md ) , "<STR_LIT>" ) <EOL> class MetaPreprocessor ( markdown . preprocessors . Preprocessor ) : <EOL> """<STR_LIT>""" <EOL> def run ( self , lines ) : <EOL> """<STR_LIT>""" <EOL> meta = { } <EOL> key = None <EOL> while <NUM_LIT:1> : <EOL> line = lines . pop ( <NUM_LIT:0> ) <EOL> if line . strip ( ) == '<STR_LIT>' : <EOL> break <EOL> m1 = META_RE . match ( line ) <EOL> if m1 : <EOL> key = m1 . group ( '<STR_LIT:key>' ) . lower ( ) . strip ( ) <EOL> meta [ key ] = [ m1 . group ( '<STR_LIT:value>' ) . strip ( ) ] <EOL> else : <EOL> m2 = META_MORE_RE . match ( line ) <EOL> if m2 and key : <EOL> meta [ key ] . append ( m2 . group ( '<STR_LIT:value>' ) . strip ( ) ) <EOL> else : <EOL> lines . insert ( <NUM_LIT:0> , line ) <EOL> break <EOL> self . markdown . Meta = meta <EOL> return lines <EOL> def makeExtension ( configs = { } ) : <EOL> return MetaExtension ( configs = configs ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> import doctest <EOL> doctest . testmod ( ) </s>
