TXT Input: Support direct conversion of files with extensions md, markdown and textile. Fixes #912931 (Add md to recognized input extensions)

This commit is contained in:
Kovid Goyal 2012-01-07 14:56:17 +05:30
parent 0f28eb6d3c
commit 0e13ef3ea5
2 changed files with 8 additions and 2 deletions

View File

@ -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):

View File

@ -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: