AZW3 input: Put internal links into quotes to avoid parse errors when tweaking

This commit is contained in:
Kovid Goyal 2013-12-11 15:55:18 +05:30
parent 95ed2862a6
commit c7aa9c78fb

View File

@ -45,7 +45,8 @@ def update_internal_links(mobi8_reader, log):
suffix = (b'#' + idtag) if idtag else b'' suffix = (b'#' + idtag) if idtag else b''
replacement = filename.split('/')[-1].encode( replacement = filename.split('/')[-1].encode(
mr.header.codec) + suffix mr.header.codec) + suffix
tag = posfid_index_pattern.sub(replacement, tag, 1) replacement = replacement.replace(b'"', b'"')
tag = posfid_index_pattern.sub(b'"' + replacement + b'"', tag, 1)
srcpieces[j] = tag srcpieces[j] = tag
raw = b''.join(srcpieces) raw = b''.join(srcpieces)
parts.append(raw.decode(mr.header.codec)) parts.append(raw.decode(mr.header.codec))