diff --git a/src/calibre/ebooks/oeb/transforms/flatcss.py b/src/calibre/ebooks/oeb/transforms/flatcss.py index 2bd300beab..b736458a87 100644 --- a/src/calibre/ebooks/oeb/transforms/flatcss.py +++ b/src/calibre/ebooks/oeb/transforms/flatcss.py @@ -474,7 +474,7 @@ class CSSFlattener(object): # lower() because otherwise if the document uses the same class # name with different case, both cases will apply, leading # to incorrect results. - klass = ascii_text(STRIPNUM.sub('', classes.split()[0])).lower() + klass = ascii_text(STRIPNUM.sub('', classes.split()[0])).lower().strip().replace(' ', '_') if css in styles: match = styles[css] else: