#NEWLINE# def expand_to_xml_node( string , start , end ) : #NEWLINE# #INDENT# tag_properties = get_tag_properties ( string [ start : end ] ) #NEWLINE# if tag_properties : #NEWLINE# #INDENT# tag_name = tag_properties [ 'name' ] #NEWLINE# if ( tag_properties [ 'type' ] == 'closing' ) : #NEWLINE# #INDENT# stringStartToTagStart = string [ : start ] #NEWLINE# openingTagPosition = find_tag ( stringStartToTagStart , 'backward' , tag_name ) #NEWLINE# if openingTagPosition : #NEWLINE# #INDENT# return utils . create_return_obj ( openingTagPosition [ 'start' ] , tag_name , string , 'complete_node' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( tag_properties [ 'type' ] == 'opening' ) : #NEWLINE# #INDENT# stringNodeEndToStringEnd = string [ end : ] #NEWLINE# closingTagPosition = find_tag ( stringNodeEndToStringEnd , 'forward' , tag_name ) #NEWLINE# if closingTagPosition : #NEWLINE# #INDENT# return utils . create_return_obj ( start , ( end + closingTagPosition [ 'end' ] ) , string , 'complete_node' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# is_within_tag_result = is_within_tag ( string , start , end ) #NEWLINE# if is_within_tag_result : #NEWLINE# #INDENT# inner_start = ( is_within_tag_result [ 'start' ] + 1 ) #NEWLINE# inner_end = ( is_within_tag_result [ 'end' ] - 1 ) #NEWLINE# if ( ( start == inner_start ) and ( end == inner_end ) ) : #NEWLINE# #INDENT# return utils . create_return_obj ( is_within_tag_result [ 'start' ] , is_within_tag_result [ 'end' ] , string , 'complete_node' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return utils . create_return_obj ( inner_start , inner_end , string , 'inner_node' ) #NEWLINE# #UNINDENT# #UNINDENT# stringStartToSelectionStart = string [ : start ] #NEWLINE# parent_opening_tag = find_tag ( stringStartToSelectionStart , 'backward' ) #NEWLINE# if parent_opening_tag : #NEWLINE# #INDENT# stringNodeEndToStringEnd = string [ parent_opening_tag [ 'end' ] : ] #NEWLINE# closingTagPosition = find_tag ( stringNodeEndToStringEnd , 'forward' , parent_opening_tag [ 'name' ] ) #NEWLINE# if closingTagPosition : #NEWLINE# #INDENT# newStart = parent_opening_tag [ 'end' ] #NEWLINE# newEnd = ( parent_opening_tag [ 'end' ] + closingTagPosition [ 'start' ] ) #NEWLINE# if ( ( newStart == start ) and ( newEnd == end ) ) : #NEWLINE# #INDENT# newStart = parent_opening_tag [ 'start' ] #NEWLINE# newEnd = ( parent_opening_tag [ 'end' ] + closingTagPosition [ 'end' ] ) #NEWLINE# #UNINDENT# return utils . create_return_obj ( newStart , newEnd , string , 'parent_node_content' )