From 032c2b0fdcf7fc22d755b14624ac3b48a991eed6 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 23 Jun 2009 07:42:30 -0700 Subject: [PATCH] Add option to control line length when preprocessing PDF input --- src/calibre/ebooks/conversion/plumber.py | 2 +- src/calibre/ebooks/conversion/preprocess.py | 6 ++++-- src/calibre/ebooks/html/input.py | 5 +++++ src/calibre/ebooks/pdf/input.py | 2 ++ src/calibre/trac/plugins/templates/linux.html | 5 +++++ 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/calibre/ebooks/conversion/plumber.py b/src/calibre/ebooks/conversion/plumber.py index e9b9051159..678c21f4ab 100644 --- a/src/calibre/ebooks/conversion/plumber.py +++ b/src/calibre/ebooks/conversion/plumber.py @@ -694,7 +694,7 @@ def create_oebbook(log, path_or_stream, opts, input_plugin, reader=None, ''' from calibre.ebooks.oeb.base import OEBBook html_preprocessor = HTMLPreProcessor(input_plugin.preprocess_html, - opts.preprocess_html) + opts.preprocess_html, getattr(opts, 'pdf_line_length', 0.5)) oeb = OEBBook(log, html_preprocessor, pretty_print=opts.pretty_print, input_encoding=encoding) if not populate: diff --git a/src/calibre/ebooks/conversion/preprocess.py b/src/calibre/ebooks/conversion/preprocess.py index a2794d94ec..cad247c48d 100644 --- a/src/calibre/ebooks/conversion/preprocess.py +++ b/src/calibre/ebooks/conversion/preprocess.py @@ -159,9 +159,11 @@ class HTMLPreProcessor(object): (re.compile('<]*?id=subtitle[^><]*?>(.*?)', re.IGNORECASE|re.DOTALL), lambda match : '

%s

'%(match.group(1),)), ] - def __init__(self, input_plugin_preprocess, plugin_preprocess): + def __init__(self, input_plugin_preprocess, plugin_preprocess, + pdf_line_length): self.input_plugin_preprocess = input_plugin_preprocess self.plugin_preprocess = plugin_preprocess + self.pdf_line_length = pdf_line_length def is_baen(self, src): return re.compile(r'
+

Note

+

+ If your kernel is compiled with CONFIG_SYSFS_DEPRECATED device detection may not work. +

+

Dependencies

${app} has the following dependencies (the listed version is the minimum version)