From 4422ba06b9d8115d510103fa6e224464659bdd34 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 16 May 2018 15:20:53 +0530 Subject: [PATCH] DOCX Input: Fix incorrect conversion of a framed block that contains a list. Fixes #1771279 [wrong tags order in list from DOCX](https://bugs.launchpad.net/calibre/+bug/1771279) --- src/calibre/ebooks/docx/to_html.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/calibre/ebooks/docx/to_html.py b/src/calibre/ebooks/docx/to_html.py index 7924f1c09e..12c25a3d63 100644 --- a/src/calibre/ebooks/docx/to_html.py +++ b/src/calibre/ebooks/docx/to_html.py @@ -741,6 +741,17 @@ class Convert(object): parent = ul.getparent() idx = parent.index(ul) frame = DIV(ul) + elif {p.tag for p in paras} & {'li'}: + def top_level_tag(x): + while True: + q = x.getparent() + if q is parent or q is None: + break + x = q + return x + paras = tuple(map(top_level_tag, paras)) + idx = parent.index(paras[0]) + frame = DIV(*paras) else: idx = parent.index(paras[0]) frame = DIV(*paras)