From 66809fb86d68650423ea3e854fb465be068b845c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 10 Apr 2009 08:41:42 -0700 Subject: [PATCH] Fix #2256 (Interresting bug with epub format) --- src/calibre/web/feeds/news.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/calibre/web/feeds/news.py b/src/calibre/web/feeds/news.py index 8f4739c197..a3642b0a33 100644 --- a/src/calibre/web/feeds/news.py +++ b/src/calibre/web/feeds/news.py @@ -1034,6 +1034,28 @@ class BasicNewsRecipe(object, LoggingInterface): nmassage.extend(entity_replace) return BeautifulSoup(raw, markupMassage=nmassage) + @classmethod + def adeify_images(cls, soup): + ''' + If your recipe when converted to EPUB has problems with images when + viewed in Adobe Digital Editions, call this method from within + :method:`postprocess_html`. + ''' + for item in soup.findAll('img'): + for attrib in ['height','width','border','align','style']: + if item.has_key(attrib): + del item[attrib] + oldParent = item.parent + myIndex = oldParent.contents.index(item) + item.extract() + divtag = Tag(soup,'div') + brtag = Tag(soup,'br') + oldParent.insert(myIndex,divtag) + divtag.append(item) + divtag.append(brtag) + return soup + + class CustomIndexRecipe(BasicNewsRecipe): def custom_index(self):