AZW3 Output: Handle the case of a link pointing to the last line of text in the document. Fixes #1011330 (cannot convert rtf to azw3)

This commit is contained in:
Kovid Goyal 2012-06-11 15:10:42 +05:30
parent 7f321ef0d9
commit 0ed633752a

View File

@ -372,6 +372,11 @@ class Chunker(object):
# the chunk immediately after
pos_fid = (chunk.sequence_number, 0, offset)
break
if chunk is self.chunk_table[-1]:
# This can happen for aids very close to the end of the the
# end of the text (https://bugs.launchpad.net/bugs/1011330)
pos_fid = (chunk.sequence_number, offset-chunk.insert_pos,
offset)
if pos_fid is None:
raise ValueError('Could not find chunk for aid: %r'%
match.group(1))