Beispiel #1
0
def _clean_for_render(text):
    whitelist = [
        'backColor', 'backcolor', 'bgcolor', 'color', 'fg', 'fontName',
        'fontSize', 'fontname', 'fontsize', 'href', 'name', 'textColor',
        'textcolor'
    ]
    html = BeautifulSoup(text)
    html.attrs = None
    for e in html.findAll(True):
        for attribute in e.attrs:
            if attribute[0] not in whitelist:
                del e[attribute[0]]
    return unicode(html)