Better handling for Mobipocket //guide/references

This commit is contained in:
Marshall T. Vandegrift 2009-01-15 12:07:29 -05:00
parent b3cc53c8d0
commit 2d9f59f4dc
2 changed files with 15 additions and 5 deletions

View File

@ -117,11 +117,15 @@ class Serializer(object):
buffer.write('<guide>')
for ref in self.oeb.guide.values():
path, frag = urldefrag(ref.href)
if hrefs[path].media_type not in OEB_DOCS or \
not ref.title:
if hrefs[path].media_type not in OEB_DOCS:
continue
buffer.write('<reference title="%s" type="%s" '
% (ref.title, ref.type))
buffer.write('<reference 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)
# Space required or won't work, I kid you not
buffer.write(' />')
@ -148,6 +152,12 @@ class Serializer(object):
def serialize_body(self):
buffer = self.buffer
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.extend([item for item in self.oeb.spine if not item.linear])
for item in spine:

View File

@ -547,7 +547,7 @@ class Guide(object):
('epigraph', 'Epigraph'), ('foreword', 'Foreword'),
('loi', 'List of Illustrations'), ('lot', 'List of Tables'),
('notes', 'Notes'), ('preface', 'Preface'),
('text', 'Begin Reading')]
('text', 'Main Text')]
TYPES = set(t for t, _ in _TYPES_TITLES)
TITLES = dict(_TYPES_TITLES)
ORDER = dict((t, i) for (t, _), i in izip(_TYPES_TITLES, count(0)))