mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Better handling for Mobipocket //guide/references
This commit is contained in:
parent
b3cc53c8d0
commit
2d9f59f4dc
@ -117,11 +117,15 @@ class Serializer(object):
|
|||||||
buffer.write('<guide>')
|
buffer.write('<guide>')
|
||||||
for ref in self.oeb.guide.values():
|
for ref in self.oeb.guide.values():
|
||||||
path, frag = urldefrag(ref.href)
|
path, frag = urldefrag(ref.href)
|
||||||
if hrefs[path].media_type not in OEB_DOCS or \
|
if hrefs[path].media_type not in OEB_DOCS:
|
||||||
not ref.title:
|
|
||||||
continue
|
continue
|
||||||
buffer.write('<reference title="%s" type="%s" '
|
buffer.write('<reference type="')
|
||||||
% (ref.title, ref.type))
|
self.serialize_text(ref.type)
|
||||||
|
buffer.write('" ')
|
||||||
|
if ref.title is not None:
|
||||||
|
buffer.write('title="')
|
||||||
|
self.serialize_text(ref.title)
|
||||||
|
buffer.write('" ')
|
||||||
self.serialize_href(ref.href)
|
self.serialize_href(ref.href)
|
||||||
# Space required or won't work, I kid you not
|
# Space required or won't work, I kid you not
|
||||||
buffer.write(' />')
|
buffer.write(' />')
|
||||||
@ -148,6 +152,12 @@ class Serializer(object):
|
|||||||
def serialize_body(self):
|
def serialize_body(self):
|
||||||
buffer = self.buffer
|
buffer = self.buffer
|
||||||
buffer.write('<body>')
|
buffer.write('<body>')
|
||||||
|
# CybookG3 'Start Reading' link
|
||||||
|
if 'text' in self.oeb.guide:
|
||||||
|
href = self.oeb.guide['text'].href
|
||||||
|
buffer.write('<a ')
|
||||||
|
self.serialize_href(href)
|
||||||
|
buffer.write(' />')
|
||||||
spine = [item for item in self.oeb.spine if item.linear]
|
spine = [item for item in self.oeb.spine if item.linear]
|
||||||
spine.extend([item for item in self.oeb.spine if not item.linear])
|
spine.extend([item for item in self.oeb.spine if not item.linear])
|
||||||
for item in spine:
|
for item in spine:
|
||||||
|
@ -547,7 +547,7 @@ class Guide(object):
|
|||||||
('epigraph', 'Epigraph'), ('foreword', 'Foreword'),
|
('epigraph', 'Epigraph'), ('foreword', 'Foreword'),
|
||||||
('loi', 'List of Illustrations'), ('lot', 'List of Tables'),
|
('loi', 'List of Illustrations'), ('lot', 'List of Tables'),
|
||||||
('notes', 'Notes'), ('preface', 'Preface'),
|
('notes', 'Notes'), ('preface', 'Preface'),
|
||||||
('text', 'Begin Reading')]
|
('text', 'Main Text')]
|
||||||
TYPES = set(t for t, _ in _TYPES_TITLES)
|
TYPES = set(t for t, _ in _TYPES_TITLES)
|
||||||
TITLES = dict(_TYPES_TITLES)
|
TITLES = dict(_TYPES_TITLES)
|
||||||
ORDER = dict((t, i) for (t, _), i in izip(_TYPES_TITLES, count(0)))
|
ORDER = dict((t, i) for (t, _), i in izip(_TYPES_TITLES, count(0)))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user