From 5ab558aca6430528e69aafb34fc53218024fda5a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 20 Aug 2009 09:10:28 -0600 Subject: [PATCH] IGN:Prefer name to id when they differ during splitting. Also use first rather than last occurrence of an id. --- src/calibre/ebooks/oeb/transforms/split.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/calibre/ebooks/oeb/transforms/split.py b/src/calibre/ebooks/oeb/transforms/split.py index d8d750eade..d639d895bf 100644 --- a/src/calibre/ebooks/oeb/transforms/split.py +++ b/src/calibre/ebooks/oeb/transforms/split.py @@ -457,10 +457,9 @@ class FlowSplitter(object): root = tree.getroot() self.files.append(self.base%i) for elem in root.xpath('//*[@id or @name]'): - anchor = elem.get('id', '') - if not anchor: - anchor = elem.get('name') - self.anchor_map[anchor] = self.files[-1] + for anchor in elem.get('id', ''), elem.get('name', ''): + if anchor != '' and anchor not in self.anchor_map: + self.anchor_map[anchor] = self.files[-1] for elem in root.xpath('//*[@%s]'%SPLIT_POINT_ATTR): elem.attrib.pop(SPLIT_POINT_ATTR, '0')