#NEWLINE# def unwrap_lines( body ) : #NEWLINE# #INDENT# lines = body . split ( '\n' ) #NEWLINE# result = '' #NEWLINE# previous_line = lines [ 0 ] #NEWLINE# for line in result [ 1 : ] : #NEWLINE# #INDENT# line = line . rstrip ( ) #NEWLINE# if ( re . match ( '^\\W' , line , flags = re . UNICODE ) and re . match ( '^\\W' , previous_line , flags = re . UNICODE ) ) : #NEWLINE# #INDENT# result += ( previous_line + '\n' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( line == '' ) or ( previous_line == '' ) or re . match ( '^\\W' , line , flags = re . UNICODE ) or different_paragraph ( previous_line , line ) ) : #NEWLINE# #INDENT# result += ( previous_line + '\n\n' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# result += ( previous_line + ' ' ) #NEWLINE# #UNINDENT# #UNINDENT# previous_line = line #NEWLINE# #UNINDENT# result += previous_line #NEWLINE# return result