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)))
|
self.anchor_map[anchor] = current_anchor = generate_anchor(anchor, frozenset(itervalues(self.anchor_map)))
|
||||||
if old_anchor is not None:
|
if old_anchor is not None:
|
||||||
# The previous anchor was not applied to any element
|
# 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:
|
if t == old_anchor:
|
||||||
self.anchor_map[a] = current_anchor
|
self.anchor_map[a] = current_anchor
|
||||||
elif x.tag.endswith('}hyperlink'):
|
elif x.tag.endswith('}hyperlink'):
|
||||||
@ -489,8 +489,18 @@ class Convert(object):
|
|||||||
if t == old_anchor:
|
if t == old_anchor:
|
||||||
self.anchor_map[a] = current_anchor
|
self.anchor_map[a] = current_anchor
|
||||||
if current_anchor is not None:
|
if current_anchor is not None:
|
||||||
# This paragraph had no <w:r> descendants
|
if dest.get('id'):
|
||||||
dest.set('id', current_anchor)
|
# 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
|
current_anchor = None
|
||||||
|
|
||||||
m = re.match(r'heading\s+(\d+)$', style.style_name or '', re.IGNORECASE)
|
m = re.match(r'heading\s+(\d+)$', style.style_name or '', re.IGNORECASE)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user