EPUB Output: Replace all whitespace in TOC items with spaces, as desktop ADE does not support non space characters.

This commit is contained in:
Kovid Goyal 2009-08-14 09:52:21 -06:00
parent 34b238a3a3
commit 20468383df
2 changed files with 9 additions and 3 deletions

View File

@ -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

View File

@ -1,7 +1,7 @@
from __future__ import with_statement
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
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: