Sync to trunk.

This commit is contained in:
John Schember 2009-06-24 07:58:08 -04:00
commit 9535021e8e
4 changed files with 15 additions and 2 deletions

View File

@ -652,6 +652,7 @@ OptionRecommendation(name='list_recipes',
line_height = self.opts.line_height line_height = self.opts.line_height
if line_height < 1e-4: if line_height < 1e-4:
line_height = None line_height = None
flattener = CSSFlattener(fbase=fbase, fkey=fkey, flattener = CSSFlattener(fbase=fbase, fkey=fkey,
lineh=line_height, lineh=line_height,
untable=self.output_plugin.file_type in ('mobi','lit'), untable=self.output_plugin.file_type in ('mobi','lit'),

View File

@ -103,6 +103,7 @@ class MobiMLizer(object):
self.oeb.manifest.remove(item) self.oeb.manifest.remove(item)
def mobimlize_spine(self): def mobimlize_spine(self):
'Iterate over the spine and convert it to MOBIML'
for item in self.oeb.spine: for item in self.oeb.spine:
stylizer = Stylizer(item.data, item.href, self.oeb, self.profile) stylizer = Stylizer(item.data, item.href, self.oeb, self.profile)
body = item.data.find(XHTML('body')) body = item.data.find(XHTML('body'))
@ -136,6 +137,7 @@ class MobiMLizer(object):
return result return result
def mobimlize_content(self, tag, text, bstate, istates): def mobimlize_content(self, tag, text, bstate, istates):
'Convert text content'
if text or tag != 'br': if text or tag != 'br':
bstate.content = True bstate.content = True
istate = istates[-1] istate = istates[-1]

View File

@ -157,6 +157,7 @@ class Stylizer(object):
rules.sort() rules.sort()
self.rules = rules self.rules = rules
self._styles = {} self._styles = {}
class_sel_pat = re.compile(r'\.[a-z]+', re.IGNORECASE)
for _, _, cssdict, text, _ in rules: for _, _, cssdict, text, _ in rules:
try: try:
selector = CSSSelector(text) selector = CSSSelector(text)
@ -164,7 +165,17 @@ class Stylizer(object):
NameError, # thrown on OS X instead of SelectorSyntaxError NameError, # thrown on OS X instead of SelectorSyntaxError
SelectorSyntaxError): SelectorSyntaxError):
continue continue
for elem in selector(tree): matches = selector(tree)
if not matches and class_sel_pat.match(text):
found = False
for x in tree.xpath('//*[@class]'):
if x.get('class').lower() == text[1:].lower():
matches.append(x)
found = True
if found:
self.logger.warn('Ignoring case mismatch for CSS selector: %s in %s'
%(text, item.href))
for elem in matches:
self.style(elem)._update_cssdict(cssdict) self.style(elem)._update_cssdict(cssdict)
for elem in xpath(tree, '//h:*[@style]'): for elem in xpath(tree, '//h:*[@style]'):
self.style(elem)._apply_style_attr() self.style(elem)._apply_style_attr()

View File

@ -141,7 +141,6 @@ class CSSFlattener(object):
bs.append('text-align: '+ \ bs.append('text-align: '+ \
('left' if self.context.dont_justify else 'justify')) ('left' if self.context.dont_justify else 'justify'))
body.set('style', '; '.join(bs)) body.set('style', '; '.join(bs))
stylizer = Stylizer(html, item.href, self.oeb, profile, stylizer = Stylizer(html, item.href, self.oeb, profile,
user_css=self.context.extra_css, user_css=self.context.extra_css,
extra_css=css) extra_css=css)