From fb92bbbf507e1be54838c638902c4e5d6c20bbcd Mon Sep 17 00:00:00 2001 From: John Schember Date: Mon, 15 Jun 2009 20:25:19 -0400 Subject: [PATCH] Fix bug 2587: Only add \n's to head if they are not alreay present. --- src/calibre/ebooks/conversion/preprocess.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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')