From 20468383df3d10669cb4693fc7b41360ce49d392 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 14 Aug 2009 09:52:21 -0600 Subject: [PATCH] EPUB Output: Replace all whitespace in TOC items with spaces, as desktop ADE does not support non space characters. --- src/calibre/ebooks/oeb/base.py | 5 ++++- src/calibre/gui2/viewer/main.py | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/calibre/ebooks/oeb/base.py b/src/calibre/ebooks/oeb/base.py index 6ef95f62d7..06220b8afa 100644 --- a/src/calibre/ebooks/oeb/base.py +++ b/src/calibre/ebooks/oeb/base.py @@ -1543,7 +1543,10 @@ class TOC(object): attrib['class'] = node.klass point = element(parent, NCX('navPoint'), attrib=attrib) label = etree.SubElement(point, NCX('navLabel')) - element(label, NCX('text')).text = node.title + title = node.title + if title: + title = re.sub(r'\s', ' ', title) + element(label, NCX('text')).text = title element(point, NCX('content'), src=urlunquote(node.href)) node.to_ncx(point) return parent diff --git a/src/calibre/gui2/viewer/main.py b/src/calibre/gui2/viewer/main.py index d29d4a9272..6cf9f5c19f 100644 --- a/src/calibre/gui2/viewer/main.py +++ b/src/calibre/gui2/viewer/main.py @@ -1,7 +1,7 @@ from __future__ import with_statement __license__ = 'GPL v3' __copyright__ = '2008, Kovid Goyal ' -import traceback, os, sys, functools, collections +import traceback, os, sys, functools, collections, re from functools import partial from threading import Thread @@ -28,7 +28,10 @@ from calibre.customize.ui import available_input_formats class TOCItem(QStandardItem): def __init__(self, toc): - QStandardItem.__init__(self, toc.text if toc.text else '') + text = toc.text + if text: + text = re.sub(r'\s', ' ', text) + QStandardItem.__init__(self, text if text else '') self.abspath = toc.abspath self.fragment = toc.fragment for t in toc: