This commit is contained in:
Kovid Goyal 2011-07-16 15:50:26 -06:00
parent dc02dbcc8e
commit b70a8d5aa9
2 changed files with 4 additions and 1 deletions

View File

@ -474,7 +474,7 @@ def strftime(fmt, t=None):
def my_unichr(num): def my_unichr(num):
try: try:
return unichr(num) return unichr(num)
except ValueError: except (ValueError, OverflowError):
return u'?' return u'?'
def entity_to_unicode(match, exceptions=[], encoding='cp1252', def entity_to_unicode(match, exceptions=[], encoding='cp1252',

View File

@ -172,6 +172,9 @@ class Serializer(object):
hrefs = self.oeb.manifest.hrefs hrefs = self.oeb.manifest.hrefs
buffer.write('<guide>') buffer.write('<guide>')
for ref in self.oeb.guide.values(): for ref in self.oeb.guide.values():
# The Kindle decides where to open a book based on the presence of
# an item in the guide that looks like
# <reference type="text" title="Start" href="chapter-one.xhtml"/>
path = urldefrag(ref.href)[0] path = urldefrag(ref.href)[0]
if path not in hrefs or hrefs[path].media_type not in OEB_DOCS: if path not in hrefs or hrefs[path].media_type not in OEB_DOCS:
continue continue