From 0e13ef3ea5b66c3a8f429737480d37e2a365ed34 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 7 Jan 2012 14:56:17 +0530 Subject: [PATCH] TXT Input: Support direct conversion of files with extensions md, markdown and textile. Fixes #912931 (Add md to recognized input extensions) --- src/calibre/ebooks/__init__.py | 3 ++- src/calibre/ebooks/txt/input.py | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/__init__.py b/src/calibre/ebooks/__init__.py index 5af555a83f..c28b6ca7af 100644 --- a/src/calibre/ebooks/__init__.py +++ b/src/calibre/ebooks/__init__.py @@ -30,7 +30,8 @@ BOOK_EXTENSIONS = ['lrf', 'rar', 'zip', 'rtf', 'lit', 'txt', 'txtz', 'text', 'ht 'html', 'htmlz', 'xhtml', 'pdf', 'pdb', 'pdr', 'prc', 'mobi', 'azw', 'doc', 'epub', 'fb2', 'djv', 'djvu', 'lrx', 'cbr', 'cbz', 'cbc', 'oebzip', 'rb', 'imp', 'odt', 'chm', 'tpz', 'azw1', 'pml', 'pmlz', 'mbp', 'tan', 'snb', - 'xps', 'oxps', 'azw4', 'book', 'zbf', 'pobi', 'docx'] + 'xps', 'oxps', 'azw4', 'book', 'zbf', 'pobi', 'docx', 'md', + 'textile', 'markdown'] class HTMLRenderer(object): diff --git a/src/calibre/ebooks/txt/input.py b/src/calibre/ebooks/txt/input.py index 99f7035800..49c8a2129d 100644 --- a/src/calibre/ebooks/txt/input.py +++ b/src/calibre/ebooks/txt/input.py @@ -22,7 +22,7 @@ class TXTInput(InputFormatPlugin): name = 'TXT Input' author = 'John Schember' description = 'Convert TXT files to HTML' - file_types = set(['txt', 'txtz', 'text']) + file_types = set(['txt', 'txtz', 'text', 'md', 'textile', 'markdown']) options = set([ OptionRecommendation(name='paragraph_type', recommended_value='auto', @@ -77,6 +77,11 @@ class TXTInput(InputFormatPlugin): txt += tf.read() + '\n\n' else: txt = stream.read() + if file_ext in {'md', 'textile', 'markdown'}: + options.formatting_type = {'md': 'markdown'}.get(file_ext, file_ext) + log.info('File extension indicates particular formatting. ' + 'Forcing formatting type to: %s'%options.formatting_type) + options.paragraph_type = 'off' # Get the encoding of the document. if options.input_encoding: