mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
HTMLZ output: Make renaming of image files happen in filename order. Fixes #2072405 [EPUB to HTMLZ Converion Image Order Issue](https://bugs.launchpad.net/calibre/+bug/2072405)
This commit is contained in:
parent
eebbbf4782
commit
4175ef18ad
@ -79,14 +79,15 @@ class OEB2HTML:
|
||||
return self.links[href]
|
||||
|
||||
def map_resources(self, oeb_book):
|
||||
for item in oeb_book.manifest:
|
||||
if item.media_type in OEB_IMAGES:
|
||||
from operator import attrgetter
|
||||
images = sorted((item for item in oeb_book.manifest if item.media_type in OEB_IMAGES), key=attrgetter('href'))
|
||||
for item in images:
|
||||
if item.href not in self.images:
|
||||
ext = os.path.splitext(item.href)[1]
|
||||
fname = f'{len(self.images)}{ext}'
|
||||
fname = fname.zfill(10)
|
||||
fname = f'{len(self.images):06d}{ext}'
|
||||
self.images[item.href] = fname
|
||||
if item in oeb_book.spine:
|
||||
|
||||
for item in oeb_book.spine:
|
||||
self.get_link_id(item.href)
|
||||
root = item.data.find(XHTML('body'))
|
||||
link_attrs = set(html.defs.link_attrs)
|
||||
@ -96,7 +97,7 @@ class OEB2HTML:
|
||||
try:
|
||||
if not isinstance(el.tag, string_or_bytes):
|
||||
continue
|
||||
except:
|
||||
except Exception:
|
||||
continue
|
||||
for attr in attribs:
|
||||
if attr in link_attrs:
|
||||
|
Loading…
x
Reference in New Issue
Block a user