import re

def clean_word(txt, its):
    for i in "font div span font img hr table td tr".split():
        r=re.compile(r'</?%s[^>]*>' % i)
        txt = r.sub('',txt)
    for i in [
        r'<!--.*?<![^>]*>',
        r'<.--\[if [^>]*>.*?<.\[endif]-->',
        r'<style>.*?</style>',
        r'<(\w:[^>]*?)>.*</\1>',
        r'class=".*?"',
        r'<.--.*?-->',
        r'&lt;!--.*?--&gt;',
        #r'<p[^>]*>&nbsp;</p[^>]*>',
        #r'<p[^>]*>\s*</p[^>]*>',
        r"""align=["'][^"']*["']""",
        r"""style=["'][^"']*["']""",
        r'{mso-[^}]*}',
        r'<[^>]*>((&nbsp;)|\s*)</[^>]*>',
        ]:
        r=re.compile(i, re.DOTALL)
        txt = r.sub('',txt)
    if its>0:
        return clean_word(txt, its-1)
    r = re.compile(r'(<br\s?/?>\s*){1,9999}')
    txt = r.sub("</p><p>",txt)
    return txt