mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
EPUB Output: Fix a duplicate id created in rare circumstances when splitting on page breaks. Fixes #1658744 [Duplicate ID error after converting from DOCX to EPUB](https://bugs.launchpad.net/calibre/+bug/1658744)
This commit is contained in:
parent
f8a2449d7f
commit
c85a3167e0
@ -254,7 +254,7 @@ class FlowSplitter(object):
|
|||||||
self.trees[i:i+1] = [before_tree, after_tree]
|
self.trees[i:i+1] = [before_tree, after_tree]
|
||||||
break
|
break
|
||||||
|
|
||||||
trees, ids = [], set([])
|
trees, ids = [], set()
|
||||||
for tree in self.trees:
|
for tree in self.trees:
|
||||||
root = tree.getroot()
|
root = tree.getroot()
|
||||||
if self.is_page_empty(root):
|
if self.is_page_empty(root):
|
||||||
@ -267,10 +267,10 @@ class FlowSplitter(object):
|
|||||||
if ids:
|
if ids:
|
||||||
body = self.get_body(root)
|
body = self.get_body(root)
|
||||||
if body is not None:
|
if body is not None:
|
||||||
for x in ids:
|
existing_ids = frozenset(body.xpath('//*/@id'))
|
||||||
body.insert(0, body.makeelement(XHTML('div'),
|
for x in ids - existing_ids:
|
||||||
id=x, style='height:0pt'))
|
body.insert(0, body.makeelement(XHTML('div'), id=x, style='height:0pt'))
|
||||||
ids = set([])
|
ids = set()
|
||||||
trees.append(tree)
|
trees.append(tree)
|
||||||
self.trees = trees
|
self.trees = trees
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user