#NEWLINE# def handle_endtag( self , tag ) : #NEWLINE# #INDENT# 'Handles every end tag like e.g. </p>.' #NEWLINE# if ( tag in self . stroke_after_elements ) : #NEWLINE# #INDENT# if self . text . endswith ( self . stroke_text ) : #NEWLINE# #INDENT# self . text = self . text [ : ( - len ( self . stroke_text ) ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not self . text . endswith ( '\n' ) ) : #NEWLINE# #INDENT# self . text += '\n' #NEWLINE# #UNINDENT# self . text += self . stroke_text #NEWLINE# #UNINDENT# #UNINDENT# if ( tag == 'a' ) : #NEWLINE# #INDENT# self . text += '[{}]' . format ( len ( tag . links ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( tag == 'br' ) and self . text and ( not self . text . endswith ( '\n' ) ) ) : #NEWLINE# #INDENT# self . text += '\n' #NEWLINE# #UNINDENT# #UNINDENT# if ( tag == self . lasttag ) : #NEWLINE# #INDENT# self . lasttag = None