View Single Post
Old 11-20-2010, 11:15 AM   #13
fredz
Junior Member
fredz can extract oil from cheesefredz can extract oil from cheesefredz can extract oil from cheesefredz can extract oil from cheesefredz can extract oil from cheesefredz can extract oil from cheesefredz can extract oil from cheesefredz can extract oil from cheese
 
Posts: 3
Karma: 1000
Join Date: Nov 2010
Device: Sony PRS-650
Same Problems

Same problems for me. I try to change existing recipes to force fonts and justification and it is very strange :

On command line, if I use for example the folowing extra_css attribute :

extra_css = '''
@font-face { font-family: "Fontin"; font-weight: normal; font-style: normal; src: url(res:///Data/fonts/Fontin-Regular.ttf) }
p { text-align: justify; }
@font-face { font-family: "Fontin"; font-weight: bold; font-style: normal; src: url(res:///Data/fonts/Fontin-Bold.ttf) }
'''

The html produced with ebook-convert my.recipe
produces that on the html style sections :

<style type="text/css">
@page { margin-bottom: 5.000000pt; margin-top: 5.000000pt; }
@font-face {
font-family: "Fontin";
font-weight: normal;
font-style: normal;
src: url(res:///Data/fonts/Fontin-Regular.ttf)
}

@font-face {
font-family: "Fontin";
font-weight: bold;
font-style: normal;
src: url(res:///Data/fonts/Fontin-Bold.ttf)
}
</style>

(the p { text-align: justify; } rule is not included)

I have tried several variants, and it still don't work

I am playing with "rue89" recipe, included in calibre distribution :

feeds = [(u'La Une', u'http://www.rue89.com/homepage/feed')]

no_stylesheets = True

preprocess_regexps = [
(re.compile(r'<(/?)h2>', re.IGNORECASE|re.DOTALL),
lambda match : '<'+match.group(1)+'h3>'),
(re.compile(r'<div class="print-title">([^>]+)</div>', re.IGNORECASE|re.DOTALL),
lambda match : '<h2>'+match.group(1)+'</h2>'),
(re.compile(r'<img[^>]+src="[^"]*/numeros/(\d+)[^0-9.">]*.gif"[^>]*/>', re.IGNORECASE|re.DOTALL),
lambda match : '<span style="font-family: Sans-serif; color: red; font-size:24pt; padding=2pt;">'+match.group(1)+'</span>'),
(re.compile(r'\''), lambda match: '&rsquo;'),
]

def preprocess_html(self,soup):
body = Tag(soup, 'body')
title = soup.find('h1', {'class':'title'})
content = soup.find('div', {'class':'content'})
soup.body.replaceWith(body)
body.insert(0, title)
body.insert(1, content)
return soup

remove_tags = [ dict(name='div', attrs={'class':'content_top'}),
dict(name='div', attrs={'id':'sidebar-left'}), ]


I've tested with last calibre version (0.7.29) on osx, but also with an older linux version (0.6.13).


I'm lost.


(at the beggining, I started to find how to overwrite the stylesheet.css file included with "news" epubs (generated with "fetch news"), but it is not possible. It would be much simpler to do like this anyway : if I could have my personnal "stylesheet.css" in my home folder in place of the default, it would be perfect)
fredz is offline   Reply With Quote