DOCX Input: Fix links that point to anchors placed in empty paragraphs not working. Fixes #1683017 [Bookmarks on graphics or empty paragraphs break Table of Contents](https://bugs.launchpad.net/calibre/+bug/1683017)

This commit is contained in:
Kovid Goyal 2017-04-16 18:11:01 +05:30
parent c6d46ceffa
commit 40b51ee2f4

View File

@ -464,6 +464,10 @@ class Convert(object):
for a, t in tuple(self.anchor_map.iteritems()): for a, t in tuple(self.anchor_map.iteritems()):
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:
# This paragraph had no <w:r> descendants
dest.set('id', current_anchor)
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)
if m is not None: if m is not None: