From bc669cb342dd3f271669b8c2a702232c745f4bdf Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 21 Sep 2012 09:17:27 +0530 Subject: [PATCH] Conversion: Do not error out when tags have unparseable color attributes. Fixes #1053583 (Problem while Fetching Indian Express news- repeating) --- recipes/indian_express.recipe | 6 ++++-- src/calibre/ebooks/oeb/transforms/flatcss.py | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/recipes/indian_express.recipe b/recipes/indian_express.recipe index 80a5840517..8da1db2a10 100644 --- a/recipes/indian_express.recipe +++ b/recipes/indian_express.recipe @@ -13,8 +13,10 @@ class IndianExpress(BasicNewsRecipe): #remove_tags_after = dict(name='td', attrs={'class':'newptool1'}) remove_tags = [ dict(name='iframe'), - dict(name='div', attrs={'class':['bookmarks_div', 'comment_box', 'bookmarks_div_bot', 'box']}), - dict(name='div', attrs={'id':['footer', 'tab_innerhc', 'discussion', 'google_new']}), + dict(name='div', attrs={'class':['pagination_new', 'comments_desc', + 'content_right', 'bookmarks_div', 'comment_box', 'bookmarks_div_bot', 'box']}), + dict(name='div', attrs={'id':['footer', 'tab_innerhc', 'discussion', + 'google_new', 'header_new', 'slidebox']}), dict(name='a', attrs={'class':'nobdr'}), #dict(name='span', text=':'), ] diff --git a/src/calibre/ebooks/oeb/transforms/flatcss.py b/src/calibre/ebooks/oeb/transforms/flatcss.py index 6633651a82..10b7e259ac 100644 --- a/src/calibre/ebooks/oeb/transforms/flatcss.py +++ b/src/calibre/ebooks/oeb/transforms/flatcss.py @@ -8,6 +8,7 @@ __copyright__ = '2008, Marshall T. Vandegrift ' import re, operator, math from collections import defaultdict +from xml.dom import SyntaxErr from lxml import etree import cssutils @@ -279,7 +280,7 @@ class CSSFlattener(object): if 'color' in node.attrib: try: cssdict['color'] = Property('color', node.attrib['color']).value - except ValueError: + except (ValueError, SyntaxErr): pass del node.attrib['color'] if 'bgcolor' in node.attrib: