constructs as the asinine epubchecker complains
+ # about them
+ from calibre.ebooks.oeb.base import XPath, XHTML
+ pdiv = XPath('//h:p/h:div')
+ for div in pdiv(root):
+ div.getparent().tag = XHTML('div')
+
+ # Remove the position:relative as it causes problems with some epub
+ # renderers. Remove display: block on an image inside a div as it is
+ # redundant and prevents text-align:center from working in ADE
+ imgpath = XPath('//h:div/h:img[@style]')
+ for img in imgpath(root):
+ div = img.getparent()
+ if len(div) == 1:
+ style = div.attrib['style'].replace('position:relative', '')
+ if style.startswith(';'): style = style[1:]
+ div.attrib['style'] = style
+ if img.attrib.get('style', '') == 'display: block;':
+ del img.attrib['style']
+
+ # A div/div/img construct causes text-align:center to not work in ADE
+ # so set the display of the second div to inline. This should have no
+ # effect (apart from minor vspace issues) in a compliant HTML renderer
+ # but it fixes the centering of the image via a text-align:center on
+ # the first div in ADE
+ imgpath = XPath('descendant::h:div/h:div/h:img')
+ for img in imgpath(root):
+ div2 = img.getparent()
+ div1 = div2.getparent()
+ if len(div1) == len(div2) == 1:
+ style = div2.attrib['style']
+ div2.attrib['style'] = 'display:inline;'+style
+
+
+ def filter_css(self, root, log):
style = root.xpath('//*[local-name() = "style" and @type="text/css"]')
if style:
style = style[0]
@@ -40,9 +82,6 @@ class Extract(ODF2XHTML):
extra.extend(sel_map.get(cls, []))
if extra:
x.set('class', orig + ' ' + ' '.join(extra))
- html = etree.tostring(root, encoding='utf-8',
- xml_declaration=True)
- return html
def do_filter_css(self, css):
from cssutils import parseString
@@ -86,7 +125,7 @@ class Extract(ODF2XHTML):
# the available screen real estate
html = html.replace('img { width: 100%; height: 100%; }', '')
try:
- html = self.filter_css(html, log)
+ html = self.fix_markup(html, log)
except:
log.exception('Failed to filter CSS, conversion may be slow')
with open('index.xhtml', 'wb') as f:
@@ -119,23 +158,4 @@ class ODTInput(InputFormatPlugin):
accelerators):
return Extract()(stream, '.', log)
- def postprocess_book(self, oeb, opts, log):
- # Fix
constructs as the asinine epubchecker complains
- # about them
- from calibre.ebooks.oeb.base import XPath, XHTML
- path = XPath('//h:p/h:div')
- path2 = XPath('//h:div[@style]/h:img[@style]')
- for item in oeb.spine:
- root = item.data
- if not hasattr(root, 'xpath'): continue
- for div in path(root):
- div.getparent().tag = XHTML('div')
-
- # This construct doesn't render well in HTML
- for img in path2(root):
- div = img.getparent()
- if 'position:relative' in div.attrib['style'] and len(div) == 1 \
- and 'img' in div[0].tag:
- del div.attrib['style']
-
diff --git a/src/calibre/gui2/store/stores/ebook_nl_plugin.py b/src/calibre/gui2/store/stores/ebook_nl_plugin.py
index e18ca7de72..0a79026dbb 100644
--- a/src/calibre/gui2/store/stores/ebook_nl_plugin.py
+++ b/src/calibre/gui2/store/stores/ebook_nl_plugin.py
@@ -23,9 +23,8 @@ from calibre.gui2.store.web_store_dialog import WebStoreDialog
class EBookNLStore(BasicStoreConfig, StorePlugin):
def open(self, parent=None, detail_item=None, external=False):
- url = 'http://ad.zanox.com/ppc/?19015168C29310186T'
- url_details = ('http://ad.zanox.com/ppc/?19016028C1098154549T&ULP=[['
- 'http://www.ebook.nl/store/{0}]]')
+ url = 'http://www.ebook.nl/'
+ url_details = ('http://www.ebook.nl/store/{0}')
if external or self.config.get('open_external', False):
if detail_item:
diff --git a/src/calibre/gui2/store/stores/foyles_uk_plugin.py b/src/calibre/gui2/store/stores/foyles_uk_plugin.py
index fd670d2d85..0e5ccfad01 100644
--- a/src/calibre/gui2/store/stores/foyles_uk_plugin.py
+++ b/src/calibre/gui2/store/stores/foyles_uk_plugin.py
@@ -6,7 +6,7 @@ __license__ = 'GPL 3'
__copyright__ = '2011, John Schember '
__docformat__ = 'restructuredtext en'
-import urllib2
+import urllib2, re
from contextlib import closing
from lxml import html
@@ -67,7 +67,10 @@ class FoylesUKStore(BasicStoreConfig, StorePlugin):
title = ''.join(data.xpath('.//a[@class="Title"]/text()'))
author = ', '.join(data.xpath('.//span[@class="Author"]/text()'))
price = ''.join(data.xpath('./ul/li[@class="Strong"]/text()'))
- price = price[price.rfind(' '):]
+ mo = re.search('£[\d\.]+', price)
+ if mo is None:
+ continue
+ price = mo.group(0)
counter -= 1
diff --git a/src/calibre/library/server/browse.py b/src/calibre/library/server/browse.py
index fd9e568163..5b7d732820 100644
--- a/src/calibre/library/server/browse.py
+++ b/src/calibre/library/server/browse.py
@@ -873,7 +873,7 @@ class BrowseServer(object):
suffix=_('in search')+': '+xml(query))
return self.browse_template(sort, category=False, initial_search=query).format(
title=_('Matching books'),
- script='booklist();', main=html)
+ script='search_result();', main=html)
# }}}