#NEWLINE# def run( self , tree ) : #NEWLINE# #INDENT# 'Apply inline patterns to a parsed Markdown tree.\n\n        Iterate over ElementTree, find elements with inline tag, apply inline\n        patterns and append newly created Elements to tree.  If you don\'t\n        want to process your data with inline paterns, instead of normal\n        string, use subclass AtomicString:\n\n            node.text = markdown.AtomicString("This will not be processed.")\n\n        Arguments:\n\n        * tree: ElementTree object, representing Markdown tree.\n\n        Returns: ElementTree object with applied inline patterns.\n\n        ' #NEWLINE# self . stashed_nodes = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# stack = [ tree ] #NEWLINE# while stack : #NEWLINE# #INDENT# currElement = stack . pop ( ) #NEWLINE# insertQueue = [ ] #NEWLINE# for child in currElement : #NEWLINE# #INDENT# if ( child . text and ( not isinstance ( child . text , util . AtomicString ) ) ) : #NEWLINE# #INDENT# text = child . text #NEWLINE# child . text = None #NEWLINE# lst = self . __processPlaceholders ( self . __handleInline ( text ) , child ) #NEWLINE# stack += lst #NEWLINE# insertQueue . append ( ( child , lst ) ) #NEWLINE# #UNINDENT# if child . tail : #NEWLINE# #INDENT# tail = self . __handleInline ( child . tail ) #NEWLINE# dumby = util . etree . Element ( 'd' ) #NEWLINE# child . tail = None #NEWLINE# tailResult = self . __processPlaceholders ( tail , dumby , False ) #NEWLINE# if dumby . tail : #NEWLINE# #INDENT# child . tail = dumby . tail #NEWLINE# #UNINDENT# pos = ( list ( currElement ) . index ( child ) + 1 ) #NEWLINE# tailResult . reverse ( ) #NEWLINE# for newChild in tailResult : #NEWLINE# #INDENT# currElement . insert ( pos , newChild ) #NEWLINE# #UNINDENT# #UNINDENT# if len ( stack ) : #NEWLINE# #INDENT# stack . append ( child ) #NEWLINE# #UNINDENT# #UNINDENT# for ( element , lst ) in insertQueue : #NEWLINE# #INDENT# if self . markdown . enable_attributes : #NEWLINE# #INDENT# if ( element . text and isString ( element . text ) ) : #NEWLINE# #INDENT# element . text = inlinepatterns . handleAttributes ( element . text , element ) #NEWLINE# #UNINDENT# #UNINDENT# i = 0 #NEWLINE# for newChild in lst : #NEWLINE# #INDENT# if self . markdown . enable_attributes : #NEWLINE# #INDENT# if ( newChild . tail and isString ( newChild . tail ) ) : #NEWLINE# #INDENT# newChild . tail = inlinepatterns . handleAttributes ( newChild . tail , element ) #NEWLINE# #UNINDENT# if ( newChild . text and isString ( newChild . text ) ) : #NEWLINE# #INDENT# newChild . text = inlinepatterns . handleAttributes ( newChild . text , newChild ) #NEWLINE# #UNINDENT# #UNINDENT# element . insert ( i , newChild ) #NEWLINE# i += 1 #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return tree