From 02a28056dee2b727eac28762d6e8736366e7c9a5 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 6 Jun 2013 13:52:31 +0530 Subject: [PATCH] DOCX: Fix incorrect styling of hyperlinks The tags for hyperlinks are not children of , use the ancestor axis instead of getparent(). --- src/calibre/ebooks/docx/styles.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/docx/styles.py b/src/calibre/ebooks/docx/styles.py index abf6fc68ca..18eeed6802 100644 --- a/src/calibre/ebooks/docx/styles.py +++ b/src/calibre/ebooks/docx/styles.py @@ -265,7 +265,8 @@ class Styles(object): def resolve_run(self, r): ans = self.run_cache.get(r, None) if ans is None: - p = r.getparent() + p = XPath('ancestor::w:p[1]')(r) + p = p[0] if p else None ans = self.run_cache[r] = RunStyle() direct_formatting = None for rPr in XPath('./w:rPr')(r):