Fix parsing of <style> tags for report

This commit is contained in:
Kovid Goyal 2015-01-22 22:05:21 +05:30
parent 181dacb662
commit 5f35a590d8

View File

@ -9,7 +9,7 @@ __copyright__ = '2015, Kovid Goyal <kovid at kovidgoyal.net>'
import posixpath, os, time, types, re import posixpath, os, time, types, re
from collections import namedtuple, defaultdict, Counter from collections import namedtuple, defaultdict, Counter
from calibre import prepare_string_for_xml from calibre import prepare_string_for_xml, force_unicode
from calibre.ebooks.oeb.base import XPath from calibre.ebooks.oeb.base import XPath
from calibre.ebooks.oeb.polish.container import OEB_DOCS, OEB_STYLES, OEB_FONTS from calibre.ebooks.oeb.polish.container import OEB_DOCS, OEB_STYLES, OEB_FONTS
from calibre.ebooks.oeb.polish.css import build_selector, PSEUDO_PAT, MIN_SPACE_RE from calibre.ebooks.oeb.polish.css import build_selector, PSEUDO_PAT, MIN_SPACE_RE
@ -157,7 +157,7 @@ def css_data(container, book_locale):
for style in style_path(container.parsed(name)): for style in style_path(container.parsed(name)):
if style.get('type', 'text/css') == 'text/css' and style.text: if style.get('type', 'text/css') == 'text/css' and style.text:
html_sheets[name].append( html_sheets[name].append(
css_rules(name, parser.parse_stylesheet(container.raw_data(name)).rules, style.sourceline)) css_rules(name, parser.parse_stylesheet(force_unicode(style.text, 'utf-8')).rules, style.sourceline - 1))
rule_map = defaultdict(lambda : defaultdict(list)) rule_map = defaultdict(lambda : defaultdict(list))
pseudo_pat = re.compile(PSEUDO_PAT, re.I) pseudo_pat = re.compile(PSEUDO_PAT, re.I)