From 68e26b945c30d0dd9106d925dbb43b964df79add Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 26 Apr 2012 11:05:05 +0530 Subject: [PATCH] KF8 Input: Handle images referenced via CSS url in the style attribute of a tag --- src/calibre/ebooks/mobi/reader/markup.py | 36 ++++++++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/src/calibre/ebooks/mobi/reader/markup.py b/src/calibre/ebooks/mobi/reader/markup.py index 8bb7f211f3..8a06bc346a 100644 --- a/src/calibre/ebooks/mobi/reader/markup.py +++ b/src/calibre/ebooks/mobi/reader/markup.py @@ -223,15 +223,15 @@ def insert_images_into_markup(parts, resource_map, log): # Handle any embedded raster images links in the xhtml text # kindle:embed:XXXX?mime=image/gif (png, jpeg, etc) (used for images) img_pattern = re.compile(r'''(<[img\s|image\s][^>]*>)''', re.IGNORECASE) - img_index_pattern = re.compile(r'''['"]kindle:embed:([0-9|A-V]+)[^'"]*['"]''') + img_index_pattern = re.compile(r'''[('"]kindle:embed:([0-9|A-V]+)[^')"]*[)'"]''') + + style_pattern = re.compile(r'''(<[a-zA-Z0-9]+\s[^>]*style\s*=\s*[^>]*>)''', + re.IGNORECASE) + for i in xrange(len(parts)): part = parts[i] - #[partnum, dir, filename, beg, end, aidtext] = self.k8proc.partinfo[i] - - # links to raster image files - # image_pattern srcpieces = img_pattern.split(part) - for j in range(1, len(srcpieces), 2): + for j in xrange(1, len(srcpieces), 2): tag = srcpieces[j] if tag.startswith(']*>)''', re.IGNORECASE)