#NEWLINE# def htmlToText( s , tagReplace = ' ' ) : #NEWLINE# #INDENT# 'Turns HTML into text.  tagReplace is a string to replace HTML tags with.\n    ' #NEWLINE# encoding = getEncoding ( s ) #NEWLINE# if encoding : #NEWLINE# #INDENT# s = s . decode ( encoding ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# if ( minisix . PY2 or isinstance ( s , bytes ) ) : #NEWLINE# #INDENT# s = s . decode ( 'utf8' ) #NEWLINE# #UNINDENT# #UNINDENT# except : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# x = HtmlToText ( tagReplace ) #NEWLINE# x . feed ( s ) #NEWLINE# x . close ( ) #NEWLINE# return x . getText ( )