diff --git a/src/calibre/ebooks/conversion/preprocess.py b/src/calibre/ebooks/conversion/preprocess.py index 1cbec251e3..8081dce325 100644 --- a/src/calibre/ebooks/conversion/preprocess.py +++ b/src/calibre/ebooks/conversion/preprocess.py @@ -21,7 +21,9 @@ def sanitize_head(match): x = match.group(1) x = _span_pat.sub('', x) - return '\n'+x+'\n' + x = ('\n%s' % x) if not x.startswith('\n') else x + x += '\n' if not x.endswith('\n') else '' + return '%s' % x def chap_head(match): chap = match.group('chap')