diff --git a/src/calibre/ebooks/conversion/preprocess.py b/src/calibre/ebooks/conversion/preprocess.py index 3b1239814a..92c2fe5954 100644 --- a/src/calibre/ebooks/conversion/preprocess.py +++ b/src/calibre/ebooks/conversion/preprocess.py @@ -389,6 +389,7 @@ class HTMLPreProcessor(object): if is_pdftohtml: end_rules.append((re.compile(r'
\s*(?P \s*(?P )?'), chap_head),)
+ length = -1
if getattr(self.extra_opts, 'unwrap_factor', 0.0) > 0.01:
length = line_length('pdf', html, getattr(self.extra_opts, 'unwrap_factor'))
if length:
@@ -425,7 +426,7 @@ class HTMLPreProcessor(object):
for rule in rules + end_rules:
html = rule[0].sub(rule[1], html)
- if is_pdftohtml:
+ if is_pdftohtml and length > -1:
# Dehyphenate
dehyphenator = Dehyphenator()
html = dehyphenator(html,'pdf', length)