From 73af726c711e538e203831716a42d2d9709cbfc9 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 3 Mar 2009 17:18:16 -0800 Subject: [PATCH] Fix #1977 (Error on converting zip with html to ePUB u'invalid literal for float(): +2) --- src/calibre/ebooks/html.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/html.py b/src/calibre/ebooks/html.py index f6f5f62720..40e882c2af 100644 --- a/src/calibre/ebooks/html.py +++ b/src/calibre/ebooks/html.py @@ -845,7 +845,12 @@ class Processor(Parser): except: size = '3' if size and size.strip() and size.strip()[0] in ('+', '-'): - size = 3 + float(size) # Hack assumes basefont=3 + size = re.search(r'[+-]{0,1}[\d\.]+', size) + try: + size = float(size.group()) + except: + size = 0 + size += 3 # Hack assumes basefont=3 try: setting = 'font-size: %d%%;'%int((float(size)/3) * 100) except ValueError: