Exemplo n.º 1
0
def convert_oo_to_html_and_xhtml(input): 
    from oo_converters import convert   
    html_input, images = convert(input, 'html')
    xhtml_input, _not_used_ = convert(input, 'xhtml')
    enc = chardet.detect(xhtml_input)['encoding']
    try_encodings = [enc, 'utf8', 'latin1']
    for encoding in try_encodings:
        try:
            res_content_html = unicode(html_input, encoding)
            res_content_xhtml = unicode(xhtml_input, encoding)
            break;
        except UnicodeDecodeError:
            pass

    res_content_xhtml = fix_img_path(res_content_html, res_content_xhtml, images)
    res_content_html = fix_html_img_path(res_content_html)
    
    if not res_content_html or not res_content_xhtml:
        raise Exception('UnicodeDecodeError: could not decode')
    return res_content_html, cleanup(res_content_xhtml), images
Exemplo n.º 2
0
def convert_oo_to_html(input):
    from oo_converters import convert    
    html_input, images = convert(input, 'html')
    
    enc = chardet.detect(html_input)['encoding']
    try_encodings = [enc, 'utf8', 'latin1']
    for encoding in try_encodings:
        try:
            res_content_html = unicode(html_input, encoding)
            break;
        except UnicodeDecodeError:
            pass
    if not res_content_html:
        raise Exception('UnicodeDecodeError: could not decode')
    return res_content_html, images