#NEWLINE# def _split_lines( self , text , width ) : #NEWLINE# #INDENT# lines = list ( ) #NEWLINE# main_indent = len ( re . match ( '( *)' , text ) . group ( 1 ) ) #NEWLINE# for line in text . splitlines ( ) : #NEWLINE# #INDENT# indent = len ( re . match ( '( *)' , line ) . group ( 1 ) ) #NEWLINE# list_match = re . match ( '( *)(([*-+>]+|\\w+\\)|\\w+\\.) +)' , new_lines ) #NEWLINE# if list_match : #NEWLINE# #INDENT# sub_indent = ( indent + len ( list_match . group ( 2 ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# sub_indent = indent #NEWLINE# #UNINDENT# line = self . _whitespace_matcher . sub ( ' ' , line ) . strip ( ) #NEWLINE# new_lines = textwrap . wrap ( text = line , width = width , initial_indent = ( ' ' * ( indent - main_indent ) ) , subsequent_indent = ( ' ' * ( sub_indent - main_indent ) ) ) #NEWLINE# lines . extend ( ( new_lines or [ ' ' ] ) ) #NEWLINE# #UNINDENT# return lines