src/cm/converters/__init__.py
changeset 78 dda94db1149a
parent 77 fe91eb717a96
child 118 75d94dd14511
equal deleted inserted replaced
77:fe91eb717a96 78:dda94db1149a
    33         
    33         
    34         xhtml_input, attachs = convert_oo_to_html(input)
    34         xhtml_input, attachs = convert_oo_to_html(input)
    35         converted_input = pandoc_convert(xhtml_input, 'html', format)
    35         converted_input = pandoc_convert(xhtml_input, 'html', format)
    36         
    36         
    37     ##############################
    37     ##############################
    38     # anything looks like text -> markdown
       
    39     elif mime_type in ['text/plain',
       
    40                        'text/english',
       
    41                        'text/enriched'
       
    42                       ]:
       
    43         converted_input = to_unicode(input)
       
    44         
       
    45     ##############################
       
    46     # anything looks like code: put them into markdown citation
    38     # anything looks like code: put them into markdown citation
    47     elif mime_type.startswith('text/x-') or mime_type in ['application/x-latex',
    39     elif mime_type.startswith('text/x-') or mime_type in ['application/x-latex',
    48                                                           'application/x-ruby',
    40                                                           'application/x-ruby',
    49                        ]:
    41                        ]:
    50         converted_input = markdown_from_code(input)
    42         converted_input = markdown_from_code(input)
    54     elif mime_type in ['text/html', 'application/xhtml+xml']:
    46     elif mime_type in ['text/html', 'application/xhtml+xml']:
    55         if format == 'html':
    47         if format == 'html':
    56             converted_input = input
    48             converted_input = input
    57         else:
    49         else:
    58             converted_input = pandoc_convert(input, 'html', format)
    50             converted_input = pandoc_convert(input, 'html', format)
       
    51     ##############################
       
    52     # anything looks like text -> markdown
       
    53     elif mime_type in ['text/plain',
       
    54                        'text/english',
       
    55                        'text/enriched'
       
    56                       ]:
       
    57         converted_input = to_unicode(input)
       
    58     ##############################
       
    59     # default case: assume it's text
       
    60     else:
       
    61         converted_input = to_unicode(input)
       
    62 
    59 
    63 
    60     return converted_input, attachs
    64     return converted_input, attachs
    61     
    65     
    62 def fix_img_path(html, xhtml, imgs):
    66 def fix_img_path(html, xhtml, imgs):
    63     """
    67     """