mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
EPUB3 Input: Fix HTML titlepages that are marked using the deprecated <guide> element not being recognized.
Complements the fix for #1746794
This commit is contained in:
parent
dce369148d
commit
136e3fec18
@ -99,7 +99,24 @@ class EPUBInput(InputFormatPlugin):
|
||||
''' If there is a reference to the cover/titlepage via manifest properties, convert to
|
||||
entries in the <guide> so that the rest of the pipeline picks it up. '''
|
||||
from calibre.ebooks.metadata.opf3 import items_with_property
|
||||
removed = None
|
||||
removed = guide_titlepage_href = guide_titlepage_id = None
|
||||
|
||||
# Look for titlepages incorrectly marked in the <guide> as covers
|
||||
guide_cover, guide_elem = None, None
|
||||
for guide_elem in opf.iterguide():
|
||||
if guide_elem.get('type', '').lower() == 'cover':
|
||||
guide_cover = guide_elem.get('href', '').partition('#')[0]
|
||||
break
|
||||
if guide_cover:
|
||||
spine = list(opf.iterspine())
|
||||
if spine:
|
||||
idref = spine[0].get('idref', '')
|
||||
for x in opf.itermanifest():
|
||||
if x.get('id') == idref and x.get('href') == guide_cover:
|
||||
guide_titlepage_href = guide_cover
|
||||
guide_titlepage_id = idref
|
||||
break
|
||||
|
||||
raster_cover_href = opf.epub3_raster_cover
|
||||
if raster_cover_href:
|
||||
self.set_guide_type(opf, 'cover', raster_cover_href, 'Cover Image')
|
||||
@ -109,6 +126,8 @@ class EPUBInput(InputFormatPlugin):
|
||||
if href and tid:
|
||||
titlepage_id, titlepage_href = tid, href.partition('#')[0]
|
||||
break
|
||||
if titlepage_href is None:
|
||||
titlepage_href, titlepage_id = guide_titlepage_href, guide_titlepage_id
|
||||
if titlepage_href is not None:
|
||||
self.set_guide_type(opf, 'titlepage', titlepage_href, 'Title Page')
|
||||
spine = list(opf.iterspine())
|
||||
|
Loading…
x
Reference in New Issue
Block a user