mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #1275 (converting opf to epub)
This commit is contained in:
parent
a4efa9b305
commit
e6d872c317
@ -30,7 +30,7 @@ def detect(aBuf):
|
||||
|
||||
# Added by Kovid
|
||||
ENCODING_PATS = [
|
||||
re.compile(r'<[^<>]+encoding=[\'"](.*?)[\'"][^<>]*>', re.IGNORECASE),
|
||||
re.compile(r'<\?[^<>]+encoding=[\'"](.*?)[\'"][^<>]*>', re.IGNORECASE),
|
||||
re.compile(r'<meta.*?content=[\'"].*?charset=([^\s\'"]+).*?[\'"].*?>', re.IGNORECASE)
|
||||
]
|
||||
ENTITY_PATTERN = re.compile(r'&(\S+?);')
|
||||
|
@ -273,8 +273,9 @@ class Spine(ResourceCollection):
|
||||
for itemref in itemrefs:
|
||||
idref = itemref.get('idref', None)
|
||||
if idref is not None:
|
||||
r = Spine.Item(s.manifest.id_for_path,
|
||||
s.manifest.path_for_id(idref), is_path=True)
|
||||
path = s.manifest.path_for_id(idref)
|
||||
if path:
|
||||
r = Spine.Item(s.manifest.id_for_path, path, is_path=True)
|
||||
r.is_linear = itemref.get('linear', 'yes') == 'yes'
|
||||
s.append(r)
|
||||
return s
|
||||
@ -439,7 +440,7 @@ class OPF(object):
|
||||
stream = open(stream, 'rb')
|
||||
self.basedir = self.base_dir = basedir
|
||||
raw, self.encoding = xml_to_unicode(stream.read(), strip_encoding_pats=True, resolve_entities=True)
|
||||
|
||||
raw = raw[raw.find('<'):]
|
||||
self.root = etree.fromstring(raw, self.PARSER)
|
||||
self.metadata = self.metadata_path(self.root)
|
||||
if not self.metadata:
|
||||
|
Loading…
x
Reference in New Issue
Block a user