From c9f0b74f111a9143f82ce9ae8dc9b0fffcc8c1a2 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 7 Aug 2009 19:12:37 -0600 Subject: [PATCH] Convert self closed
and tags to empty closed tags as many browser based renderers refuse to recognize them as closed without a proper DOCTYPE. Fixes #3095 (Some epub files can only be advanced chapter to chapter) --- src/calibre/ebooks/oeb/base.py | 5 ++++- src/calibre/ebooks/oeb/transforms/structure.py | 1 + src/calibre/manual/conversion.rst | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/oeb/base.py b/src/calibre/ebooks/oeb/base.py index 39b2fae678..993edea279 100644 --- a/src/calibre/ebooks/oeb/base.py +++ b/src/calibre/ebooks/oeb/base.py @@ -1010,7 +1010,10 @@ class Manifest(object): def __str__(self): data = self.data if isinstance(data, etree._Element): - return xml2str(data, pretty_print=self.oeb.pretty_print) + ans = xml2str(data, pretty_print=self.oeb.pretty_print) + if self.media_type in OEB_DOCS: + ans = re.sub(r'<(div|a)([^>]*)/>', r'<\1\2>', ans) + return ans if isinstance(data, unicode): return data.encode('utf-8') if hasattr(data, 'cssText'): diff --git a/src/calibre/ebooks/oeb/transforms/structure.py b/src/calibre/ebooks/oeb/transforms/structure.py index d5d17cdd07..c377a8b3a8 100644 --- a/src/calibre/ebooks/oeb/transforms/structure.py +++ b/src/calibre/ebooks/oeb/transforms/structure.py @@ -78,6 +78,7 @@ class DetectStructure(object): page_break_after = 'display: block; page-break-after: always' for item, elem in self.detected_chapters: text = u' '.join([t.strip() for t in elem.xpath('descendant::text()')]) + text = text.strip() self.log('\tDetected chapter:', text[:50]) if chapter_mark == 'none': continue diff --git a/src/calibre/manual/conversion.rst b/src/calibre/manual/conversion.rst index 848c7477c0..15a4e869bd 100644 --- a/src/calibre/manual/conversion.rst +++ b/src/calibre/manual/conversion.rst @@ -4,3 +4,5 @@ E-book Conversion =================== + +This section is under construction. In the meantime, you can see some documentation of the command line interface to conversion at :ref:`ebook-convert`.