From 15aadb14c428add63351eea4b85c5c1fe25ea789 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 20 Jan 2016 00:17:36 +0530 Subject: [PATCH] Edit Book: Fix error when merging an empty HTML document or one that contains only text and no tags. Fixes #1535427 [Edit ebook, merge selected text files fail.](https://bugs.launchpad.net/calibre/+bug/1535427) --- src/calibre/ebooks/oeb/polish/split.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/oeb/polish/split.py b/src/calibre/ebooks/oeb/polish/split.py index 1cffbb4dd4..929abaa821 100644 --- a/src/calibre/ebooks/oeb/polish/split.py +++ b/src/calibre/ebooks/oeb/polish/split.py @@ -377,8 +377,9 @@ def merge_html(container, names, master): if not isinstance(first_child, basestring): break if isinstance(first_child, basestring): - # Empty document, ignore - continue + # body contained only text, no tags + first_child = body.makeelement(XHTML('p')) + first_child.text, children[0] = children[0], first_child amap = anchor_map[name] remove_name_attributes(root)