diff --git a/src/calibre/ebooks/epub/from_html.py b/src/calibre/ebooks/epub/from_html.py index 722b6cd4e3..c358471f09 100644 --- a/src/calibre/ebooks/epub/from_html.py +++ b/src/calibre/ebooks/epub/from_html.py @@ -165,8 +165,11 @@ class HTMLProcessor(Processor, Rationalizer): br.tag = 'p' br.text = u'\u00a0' if (br.tail and br.tail.strip()) or sibling is None or \ - getattr(sibling, 'tag', '') != 'br': - br.set('style', br.get('style', '')+'; margin: 0pt; border:0pt; height:0pt') + getattr(sibling, 'tag', '') != 'br': + style = br.get('style', '').split(';') + style = filter(None, map(lambda x: x.strip(), style)) + style.append('margin: 0pt; border:0pt; height:0pt') + br.set('style', '; '.join(style)) else: sibling.getparent().remove(sibling) if sibling.tail: diff --git a/src/calibre/ebooks/oeb/stylizer.py b/src/calibre/ebooks/oeb/stylizer.py index bf04133254..c2d12f317e 100644 --- a/src/calibre/ebooks/oeb/stylizer.py +++ b/src/calibre/ebooks/oeb/stylizer.py @@ -277,10 +277,9 @@ class Style(object): def _apply_style_attr(self): attrib = self._element.attrib if 'style' in attrib: - css = attrib['style'].strip() - if css.startswith(';'): - css = css[1:] - style = CSSStyleDeclaration(css) + css = attrib['style'].split(';') + css = filter(None, map(lambda x: x.strip(), css)) + style = CSSStyleDeclaration('; '.join(css)) self._style.update(self._stylizer.flatten_style(style)) def _has_parent(self):