From bdd9e1c027e10d689fcecd23105b3dfbde838968 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 21 Aug 2008 16:21:07 -0700 Subject: [PATCH] IGN:Handle tags in html2epub --- src/calibre/ebooks/epub/from_html.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/calibre/ebooks/epub/from_html.py b/src/calibre/ebooks/epub/from_html.py index 957b91e9bf..985f035129 100644 --- a/src/calibre/ebooks/epub/from_html.py +++ b/src/calibre/ebooks/epub/from_html.py @@ -89,6 +89,25 @@ class HTMLProcessor(PreProcessor, LoggingInterface): css.append('\n'.join(get_text(style))) style.getparent().remove(style) + font_id = 1 + for font in self.root.xpath('//font'): + try: + size = int(font.attrib.pop('size', '3')) + except: + size = 3 + setting = 'font-size: %d%%;'%int((float(size)/3) * 100) + face = font.attrib.pop('face', None) + if face is not None: + setting += 'font-face:%s;'%face + color = font.attrib.pop('color', None) + if color is not None: + setting += 'color:%s'%color + id = 'calibre_font_id_%d'%font_id + font['id'] = 'calibre_font_id_%d'%font_id + font_id += 1 + css.append('#%s { %s }'%(id, setting)) + + css_counter = 1 for elem in self.root.xpath('//*[@style]'): if 'id' not in elem.keys():