From 6a0fb8385908d08c6a3afe629a3c3584730f89bc Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 12 Jun 2013 15:21:05 +0530 Subject: [PATCH] Dont remove tags if they have ids --- src/calibre/ebooks/docx/cleanup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/ebooks/docx/cleanup.py b/src/calibre/ebooks/docx/cleanup.py index f8fe922e9b..0f6dbe011a 100644 --- a/src/calibre/ebooks/docx/cleanup.py +++ b/src/calibre/ebooks/docx/cleanup.py @@ -69,7 +69,7 @@ def cleanup_markup(root, styles): class_map = dict(styles.classes.itervalues()) parents = ('p', 'div') + tuple('h%d' % i for i in xrange(1, 7)) for parent in root.xpath('//*[(%s) and count(span)=1]' % ' or '.join('name()="%s"' % t for t in parents)): - if len(parent) == 1 and not parent.text and not parent[0].tail: + if len(parent) == 1 and not parent.text and not parent[0].tail and not parent[0].get('id', None): # We have a block whose contents are entirely enclosed in a span = parent[0] span_class = span.get('class', None)