Tweak Book: When rebuilding azw3 files handle <a> tags that have name but not id attribute, these are apparently produced by kindlegen. Fixes #1112934 (links are borken in azw3 (KF8) when tweaking book)

This commit is contained in:
Kovid Goyal 2013-02-02 12:38:43 +05:30
parent e0e1bafbca
commit b94aff86bf

View File

@ -241,6 +241,11 @@ class KF8Writer(object):
j = 0
for tag in root.iterdescendants(etree.Element):
id_ = tag.attrib.get('id', None)
if id_ is None:
# Can happen during tweaking
id_ = tag.attrib.get('name', None)
if id_ is not None:
tag.attrib['id'] = id_
if id_ is not None or barename(tag.tag).lower() in aid_able_tags:
aid = aidbase + j
tag.attrib['aid'] = to_base(aid, base=32)