From ec32d0f3f10724a55cdce3c952106414423d2a6d Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 23 Aug 2011 09:51:46 -0600 Subject: [PATCH] When adding a text indent to paragraphs as part of the remove spacing between paragraphs transformation, do not add an indent to paragraphs that are directly centerd or right aligned. Fixes #830439 ([Enhancement]Indenting should ignore centered text) --- src/calibre/ebooks/oeb/transforms/flatcss.py | 3 ++- src/calibre/library/sqlite.py | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/oeb/transforms/flatcss.py b/src/calibre/ebooks/oeb/transforms/flatcss.py index d006d8dd2d..1493a647ae 100644 --- a/src/calibre/ebooks/oeb/transforms/flatcss.py +++ b/src/calibre/ebooks/oeb/transforms/flatcss.py @@ -320,7 +320,8 @@ class CSSFlattener(object): if self.context.insert_blank_line: cssdict['margin-top'] = cssdict['margin-bottom'] = \ '%fem'%self.context.insert_blank_line_size - if self.context.remove_paragraph_spacing: + if (self.context.remove_paragraph_spacing and + cssdict.get('text-align', None) not in ('center', 'right')): cssdict['text-indent'] = "%1.1fem" % self.context.remove_paragraph_spacing_indent_size if cssdict: diff --git a/src/calibre/library/sqlite.py b/src/calibre/library/sqlite.py index b5917f1a55..90d293ba64 100644 --- a/src/calibre/library/sqlite.py +++ b/src/calibre/library/sqlite.py @@ -290,7 +290,10 @@ class DatabaseException(Exception): def __init__(self, err, tb): tb = '\n\t'.join(('\tRemote'+tb).splitlines()) - msg = unicode(err) +'\n' + tb + try: + msg = unicode(err) +'\n' + tb + except: + msg = repr(err) + '\n' + tb Exception.__init__(self, msg) self.orig_err = err self.orig_tb = tb