From a27ed258dc37a69cca0c9985db46a341eda4abb6 Mon Sep 17 00:00:00 2001 From: "Marshall T. Vandegrift" Date: Sun, 25 Jan 2009 17:15:27 -0500 Subject: [PATCH] any2* shouldn't emit empty 'class' attributes. CSSFlattener should handle empty 'class' attributes. --- src/calibre/ebooks/html.py | 2 +- src/calibre/ebooks/oeb/transforms/flatcss.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/html.py b/src/calibre/ebooks/html.py index f551121f94..f6659f9f51 100644 --- a/src/calibre/ebooks/html.py +++ b/src/calibre/ebooks/html.py @@ -836,7 +836,7 @@ class Processor(Parser): classname = 'calibre_class_%d'%class_counter class_counter += 1 cache[setting] = classname - cn = elem.get('class', '') + cn = elem.get('class', classname) elem.set('class', cn) elem.attrib.pop('style') diff --git a/src/calibre/ebooks/oeb/transforms/flatcss.py b/src/calibre/ebooks/oeb/transforms/flatcss.py index 8a3057787d..28b72b04f3 100644 --- a/src/calibre/ebooks/oeb/transforms/flatcss.py +++ b/src/calibre/ebooks/oeb/transforms/flatcss.py @@ -207,7 +207,8 @@ class CSSFlattener(object): items = cssdict.items() items.sort() css = u';\n'.join(u'%s: %s' % (key, val) for key, val in items) - klass = STRIPNUM.sub('', node.get('class', 'calibre').split()[0]) + classes = node.get('class', None) or 'calibre' + klass = STRIPNUM.sub('', classes.split()[0]) if css in styles: match = styles[css] else: