mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
DOCX Input: Fix a bookmark at the end of a paragraph causing the bookmark at the start of the paragraph to be skipped. Fixes #1942805 [Private bug](https://bugs.launchpad.net/calibre/+bug/1942805)
This commit is contained in:
parent
44bf6e3859
commit
94dbd026d0
@ -473,7 +473,7 @@ class Convert(object):
|
||||
self.anchor_map[anchor] = current_anchor = generate_anchor(anchor, frozenset(itervalues(self.anchor_map)))
|
||||
if old_anchor is not None:
|
||||
# The previous anchor was not applied to any element
|
||||
for a, t in tuple(iteritems(self.anchor_map)):
|
||||
for a, t in tuple(self.anchor_map.items()):
|
||||
if t == old_anchor:
|
||||
self.anchor_map[a] = current_anchor
|
||||
elif x.tag.endswith('}hyperlink'):
|
||||
@ -489,6 +489,16 @@ class Convert(object):
|
||||
if t == old_anchor:
|
||||
self.anchor_map[a] = current_anchor
|
||||
if current_anchor is not None:
|
||||
if dest.get('id'):
|
||||
# this bookmark was at the end of the paragraph
|
||||
if len(dest):
|
||||
if dest[-1].get('id'):
|
||||
self.anchor_map[current_anchor] = dest[-1].get('id')
|
||||
else:
|
||||
dest[-1].set('id', current_anchor)
|
||||
else:
|
||||
self.anchor_map[current_anchor] = dest.get('id')
|
||||
else:
|
||||
# This paragraph had no <w:r> descendants
|
||||
dest.set('id', current_anchor)
|
||||
current_anchor = None
|
||||
|
Loading…
x
Reference in New Issue
Block a user