コード例 #1
0
ファイル: utils.py プロジェクト: xobb1t/djangodash12
def html2text(html):
    """use html2text but repair newlines cutting urls"""
    txt = html2text_orig(html)
    links = list(link_re.finditer(txt))
    # replace links
    out = StringIO()
    pos = 0
    for l in links:
        out.write(txt[pos : l.start()])
        out.write(l.group().replace("\n", ""))
        pos = l.end()
    out.write(txt[pos:])
    return out.getvalue()
コード例 #2
0
def html2text(html):
    """Use html2text but repair newlines cutting urls.
    Need to use this hack until
    https://github.com/aaronsw/html2text/issues/#issue/7 is not fixed"""
    txt = html2text_orig(html)
    links = list(LINK_RE.finditer(txt))
    out = StringIO()
    pos = 0
    for l in links:
        out.write(txt[pos:l.start()])
        out.write(l.group().replace('\n', ''))
        pos = l.end()
    out.write(txt[pos:])
    return out.getvalue()
コード例 #3
0
ファイル: mail.py プロジェクト: Abzhora/django-userena
def html2text(html):
    """Use html2text but repair newlines cutting urls.
    Need to use this hack until
    https://github.com/aaronsw/html2text/issues/#issue/7 is not fixed"""
    txt = html2text_orig(html)
    links = list(LINK_RE.finditer(txt))
    out = StringIO()
    pos = 0
    for l in links:
        out.write(txt[pos:l.start()])
        out.write(l.group().replace('\n', ''))
        pos = l.end()
    out.write(txt[pos:])
    return out.getvalue()