def escape_html_characters(content):
 return re.sub('<!--.*-->', '', re.sub('<!\\[CDATA\\[.*\\]\\]>', '', re.sub('(\\s|&nbsp;|//)+', ' ', html_to_text(content))))

def escape_html_characters ( content ) : return re . sub ( '<!--.*-->' , '' , re . sub ( '<!\\[CDATA\\[.*\\]\\]>' , '' , re . sub ( '(\\s|&nbsp;|//)+' , ' ' , html_to_text ( content ) ) ) )
remove html characters that shouldnt be indexed using elasticsearch indexer this method is complementary to html_to_text method found in xmodule/annotator_mixin .