From 40b51ee2f4f0a0dec6bb27e2f381df22e9e46983 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 16 Apr 2017 18:11:01 +0530 Subject: [PATCH] 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) --- src/calibre/ebooks/docx/to_html.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/calibre/ebooks/docx/to_html.py b/src/calibre/ebooks/docx/to_html.py index b5c1175901..21f2ac2281 100644 --- a/src/calibre/ebooks/docx/to_html.py +++ b/src/calibre/ebooks/docx/to_html.py @@ -464,6 +464,10 @@ class Convert(object): for a, t in tuple(self.anchor_map.iteritems()): if t == old_anchor: self.anchor_map[a] = current_anchor + if current_anchor is not None: + # This paragraph had no descendants + dest.set('id', current_anchor) + current_anchor = None m = re.match(r'heading\s+(\d+)$', style.style_name or '', re.IGNORECASE) if m is not None: