From 95892f204b22f0ea2aef5a06eea99c5a6d18c82e Mon Sep 17 00:00:00 2001 From: John Schember Date: Sat, 12 Feb 2011 14:38:55 -0500 Subject: [PATCH] TXT Input: New paragraph-type option (off) to disable modifying the paragraph structure. --- src/calibre/ebooks/txt/input.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/calibre/ebooks/txt/input.py b/src/calibre/ebooks/txt/input.py index 7d218a36cf..6d958b0e7c 100644 --- a/src/calibre/ebooks/txt/input.py +++ b/src/calibre/ebooks/txt/input.py @@ -28,15 +28,18 @@ class TXTInput(InputFormatPlugin): options = set([ OptionRecommendation(name='paragraph_type', recommended_value='auto', - choices=['auto', 'block', 'single', 'print', 'unformatted'], + choices=['auto', 'block', 'single', 'print', 'unformatted', 'off'], help=_('Paragraph structure.\n' - 'choices are [\'auto\', \'block\', \'single\', \'print\', \'unformatted\']\n' + 'choices are [\'auto\', \'block\', \'single\', \'print\', \'unformatted\', \'off\']\n' '* auto: Try to auto detect paragraph type.\n' '* block: Treat a blank line as a paragraph break.\n' '* single: Assume every line is a paragraph.\n' '* print: Assume every line starting with 2+ spaces or a tab ' - 'starts a paragraph.' - '* unformatted: Most lines have hard line breaks, few/no blank lines or indents.')), + 'starts a paragraph.\n' + '* unformatted: Most lines have hard line breaks, few/no blank lines or indents. ' + 'Tries to determine structure and reformat the differentiate elements.\n' + '* off: Don\'t modify the paragraph structure. This is useful when combined with ' + 'Markdown or Textile formatting to ensure no formatting is lost.')), OptionRecommendation(name='formatting_type', recommended_value='auto', choices=['auto', 'plain', 'heuristic', 'textile', 'markdown'], help=_('Formatting used within the document.' @@ -134,7 +137,7 @@ class TXTInput(InputFormatPlugin): preprocessor = HeuristicProcessor(options, log=getattr(self, 'log', None)) txt = preprocessor.punctuation_unwrap(length, txt, 'txt') txt = separate_paragraphs_single_line(txt) - else: + elif options.paragraph_type == 'block': txt = separate_hard_scene_breaks(txt) txt = block_to_single_line(txt)