WHen pretty printing the OPF, do not sort the manifest items if there are comments in the manifest, as this would break the link between the comments and the content

This commit is contained in:
Kovid Goyal 2013-12-13 18:51:31 +05:30
parent 91b42705d9
commit eadb877113

View File

@ -78,7 +78,10 @@ def pretty_opf(root):
return (cat, i)
for manifest in root.xpath('//opf:manifest', namespaces=OPF_NAMESPACES):
children = sorted(manifest, key=manifest_key)
try:
children = sorted(manifest, key=manifest_key)
except AttributeError:
continue # There are comments so dont sort since that would mess up the comments
for x in reversed(children):
manifest.insert(0, x)