From b8be1a27b2b95c990c8c6717059adbe656a11177 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 12 Jun 2013 16:36:16 +0530 Subject: [PATCH] Use and instead of where possible --- src/calibre/ebooks/docx/cleanup.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/calibre/ebooks/docx/cleanup.py b/src/calibre/ebooks/docx/cleanup.py index a46aef50e7..4b1828e39a 100644 --- a/src/calibre/ebooks/docx/cleanup.py +++ b/src/calibre/ebooks/docx/cleanup.py @@ -84,3 +84,14 @@ def cleanup_markup(root, styles): for child in span: parent.append(child) + # Make spans whose only styling is bold or italic into and tags + for span in root.xpath('//span[@class]'): + css = class_map.get(span.get('class', None), {}) + if len(css) == 1: + if css == {'font-style':'italic'}: + span.tag = 'i' + del span.attrib['class'] + elif css == {'font-weight':'bold'}: + span.tag = 'b' + del span.attrib['class'] +