示例#1
0
文件: apa_prof.py 项目: isususi/amcat
def to_html(original_rtf, fixed_rtf):
    html = None
    from sh import unrtf

    with NamedTemporaryFile() as xml:
        xml.write(fixed_rtf)
        xml.flush()
        html = bytes(unrtf(xml.name))

    for u in get_unencoded(original_rtf):
        html = html.replace(UNDECODED, u, 1)

    html = html.decode("latin-1")

    for match, correct in get_unencoded_unicode(original_rtf):
        html = html.replace(UNDECODED_UNICODE, correct, 1)

    return html.replace("&gt;", ">").replace("&lt;", "<")
示例#2
0
def to_html(original_rtf, fixed_rtf):
    html = None
    from sh import unrtf

    with NamedTemporaryFile() as xml:
        xml.write(fixed_rtf)
        xml.flush()
        html = bytes(unrtf(xml.name))

    for u in get_unencoded(original_rtf):
        html = html.replace(UNDECODED, u, 1)

    html = html.decode("latin-1")

    for match, correct in get_unencoded_unicode(original_rtf):
        html = html.replace(UNDECODED_UNICODE, correct, 1)

    return html.replace("&gt;", ">").replace("&lt;", "<")