#NEWLINE# def format_doc( self , doc , html , indent , prefix = '' ) : #NEWLINE# #INDENT# parts = [ ] #NEWLINE# if ( not len ( doc ) ) : #NEWLINE# #INDENT# parts . append ( ( ' ' * indent ) ) #NEWLINE# parts . append ( prefix ) #NEWLINE# parts . append ( self . format_tag ( doc ) ) #NEWLINE# if ( not self . html_empty_tag ( doc , html ) ) : #NEWLINE# #INDENT# if strip ( doc . text ) : #NEWLINE# #INDENT# parts . append ( self . format_text ( doc . text ) ) #NEWLINE# #UNINDENT# parts . append ( self . format_end_tag ( doc ) ) #NEWLINE# #UNINDENT# if strip ( doc . tail ) : #NEWLINE# #INDENT# parts . append ( self . format_text ( doc . tail ) ) #NEWLINE# #UNINDENT# parts . append ( '\n' ) #NEWLINE# return '' . join ( parts ) #NEWLINE# #UNINDENT# parts . append ( ( ' ' * indent ) ) #NEWLINE# parts . append ( prefix ) #NEWLINE# parts . append ( self . format_tag ( doc ) ) #NEWLINE# if ( not self . html_empty_tag ( doc , html ) ) : #NEWLINE# #INDENT# parts . append ( '\n' ) #NEWLINE# if strip ( doc . text ) : #NEWLINE# #INDENT# parts . append ( ( ' ' * indent ) ) #NEWLINE# parts . append ( self . format_text ( doc . text ) ) #NEWLINE# parts . append ( '\n' ) #NEWLINE# #UNINDENT# for el in doc : #NEWLINE# #INDENT# parts . append ( self . format_doc ( el , html , ( indent + 2 ) ) ) #NEWLINE# #UNINDENT# parts . append ( ( ' ' * indent ) ) #NEWLINE# parts . append ( self . format_end_tag ( doc ) ) #NEWLINE# parts . append ( '\n' ) #NEWLINE# #UNINDENT# if strip ( doc . tail ) : #NEWLINE# #INDENT# parts . append ( ( ' ' * indent ) ) #NEWLINE# parts . append ( self . format_text ( doc . tail ) ) #NEWLINE# parts . append ( '\n' ) #NEWLINE# #UNINDENT# return '' . join ( self )