#NEWLINE# def insertBefore( self , node , refNode ) : #NEWLINE# #INDENT# index = self . element . index ( refNode . element ) #NEWLINE# if ( ( node . element . __class__ == NavigableString ) and self . element . contents and ( self . element . contents [ ( index - 1 ) ] . __class__ == NavigableString ) ) : #NEWLINE# #INDENT# old_node = self . element . contents [ ( index - 1 ) ] #NEWLINE# new_str = self . soup . new_string ( ( old_node + node . element ) ) #NEWLINE# old_node . replace_with ( new_str ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . element . insert ( index , node . element ) #NEWLINE# node . parent = self