From a8f065d38fdd5363142ed47232384eb7d914cb19 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 14 Aug 2009 13:55:33 -0600 Subject: [PATCH] EPUB Output: Close self closing tags explicitly as they cause problems in browser based renderers like the calibre ebook viewer. Fix #3152 (MOBI Error) --- src/calibre/__init__.py | 3 ++- src/calibre/ebooks/oeb/base.py | 2 +- src/calibre/manual/faq.rst | 9 +++++++++ src/calibre/utils/filenames.py | 11 ++++++++--- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/calibre/__init__.py b/src/calibre/__init__.py index 5219159cef..ad8f10ae06 100644 --- a/src/calibre/__init__.py +++ b/src/calibre/__init__.py @@ -88,7 +88,8 @@ def sanitize_file_name(name, substitute='_', as_unicode=False): one = re.sub(r'^\.+$', '_', one) if as_unicode: one = one.decode(filesystem_encoding) - return one.replace('..', '_') + one = one.replace('..', substitute) + return one def prints(*args, **kwargs): diff --git a/src/calibre/ebooks/oeb/base.py b/src/calibre/ebooks/oeb/base.py index 06220b8afa..3f9e6a4d4a 100644 --- a/src/calibre/ebooks/oeb/base.py +++ b/src/calibre/ebooks/oeb/base.py @@ -1016,7 +1016,7 @@ class Manifest(object): if isinstance(data, etree._Element): 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) + ans = re.sub(r'<(div|a|span)([^>]*)/>', r'<\1\2>', ans) return ans if isinstance(data, unicode): return data.encode('utf-8') diff --git a/src/calibre/manual/faq.rst b/src/calibre/manual/faq.rst index dc1563e579..fb8d378bd8 100644 --- a/src/calibre/manual/faq.rst +++ b/src/calibre/manual/faq.rst @@ -103,6 +103,15 @@ First install the Stanza reader on your iPhone from http://www.lexcycle.com . Th Now you should be able to access your books on your iPhone. +Why is my device not detected in linux? +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +|app| uses something called SYSFS to detect devices in linux. The linux kernel can export two version of SYSFS, one of which is deprecated. Some linux distributions still ship with kernels that support the deprecated version of SYSFS, even though it was deprecated a long time ago. In this case, device detection in |app| will not work. You can check what version of SYSFS is exported by your kernel with the following command:: + + grep SYSFS_DEPRECATED /boot/config-`uname -r` + +You should see something like ``CONFIG_SYSFS_DEPRECATED_V2 is not set``. + Library Management ------------------ diff --git a/src/calibre/utils/filenames.py b/src/calibre/utils/filenames.py index ba10d6934e..0aab96522b 100644 --- a/src/calibre/utils/filenames.py +++ b/src/calibre/utils/filenames.py @@ -22,9 +22,14 @@ def ascii_text(orig): return ascii -def ascii_filename(orig): - return sanitize_file_name(ascii_text(orig).replace('?', '_')) - +def ascii_filename(orig, substitute='_'): + ans = [] + orig = ascii_text(orig).replace('?', '_') + for x in orig: + if ord(x) < 32: + x = substitute + ans.append(x) + return sanitize_file_name(''.join(ans), substitute=substitute) def supports_long_names(path): t = ('a'*300)+'.txt'