From 40b6e6741ad133b011cfc1c40beee703b535f8e8 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 23 Apr 2014 09:08:53 +0530 Subject: [PATCH] Edit book: When beautifying source code, beautify the case where contains a single
or the like with all contents, even though doing so is not strictly safe. --- src/calibre/ebooks/oeb/polish/pretty.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/calibre/ebooks/oeb/polish/pretty.py b/src/calibre/ebooks/oeb/polish/pretty.py index 0c7941659e..395ff40910 100644 --- a/src/calibre/ebooks/oeb/polish/pretty.py +++ b/src/calibre/ebooks/oeb/polish/pretty.py @@ -172,6 +172,11 @@ def pretty_html_tree(container, root): pretty_xml_tree(child) for body in root.findall('h:body', namespaces=XPNSMAP): pretty_block(body) + # Special case the handling of a body that contains a single block tag + # with all content. In this case we prettify the containing block tag + # even if it has non block children. + if len(body) == 1 and not callable(body[0].tag) and isblock(body[0]) and not has_only_blocks(body[0]) and barename(body[0].tag) != 'pre': + pretty_block(body[0], level=2) if container is not None: # Handle