mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #1191 (Please support cutomized font-family css in "Section Menu", "Main Menu" and "Date") and improve Atlantic recipe
This commit is contained in:
parent
7ef3101084
commit
eff9f9b106
@ -19,7 +19,7 @@ class DefaultProfile(object):
|
|||||||
|
|
||||||
class PRS505(DefaultProfile):
|
class PRS505(DefaultProfile):
|
||||||
|
|
||||||
flow_size = 300000
|
flow_size = 270000
|
||||||
screen_size = (600, 775)
|
screen_size = (600, 775)
|
||||||
remove_special_chars = re.compile(u'[\u200b\u00ad]')
|
remove_special_chars = re.compile(u'[\u200b\u00ad]')
|
||||||
|
|
||||||
|
@ -719,6 +719,7 @@ class Processor(Parser):
|
|||||||
return id
|
return id
|
||||||
|
|
||||||
self.external_stylesheets, self.stylesheet = [], self.css_parser.parseString('')
|
self.external_stylesheets, self.stylesheet = [], self.css_parser.parseString('')
|
||||||
|
self.specified_override_css = []
|
||||||
for link in self.root.xpath('//link'):
|
for link in self.root.xpath('//link'):
|
||||||
if 'css' in link.get('type', 'text/css').lower():
|
if 'css' in link.get('type', 'text/css').lower():
|
||||||
file = os.path.join(self.tdir, *(link.get('href', '').split('/')))
|
file = os.path.join(self.tdir, *(link.get('href', '').split('/')))
|
||||||
@ -743,6 +744,7 @@ class Processor(Parser):
|
|||||||
|
|
||||||
for style in self.root.xpath('//style'):
|
for style in self.root.xpath('//style'):
|
||||||
if 'css' in style.get('type', 'text/css').lower():
|
if 'css' in style.get('type', 'text/css').lower():
|
||||||
|
override_css = style.get('title', '') == 'override_css'
|
||||||
raw = '\n'.join(style.xpath('./text()'))
|
raw = '\n'.join(style.xpath('./text()'))
|
||||||
css = self.preprocess_css(raw)
|
css = self.preprocess_css(raw)
|
||||||
try:
|
try:
|
||||||
@ -751,7 +753,10 @@ class Processor(Parser):
|
|||||||
self.log_debug('Failed to parse style element')
|
self.log_debug('Failed to parse style element')
|
||||||
else:
|
else:
|
||||||
for rule in sheet:
|
for rule in sheet:
|
||||||
self.stylesheet.add(rule)
|
if override_css:
|
||||||
|
self.specified_override_css.append(rule)
|
||||||
|
else:
|
||||||
|
self.stylesheet.add(rule)
|
||||||
style.getparent().remove(style)
|
style.getparent().remove(style)
|
||||||
cache = {}
|
cache = {}
|
||||||
class_counter = 0
|
class_counter = 0
|
||||||
@ -806,6 +811,8 @@ class Processor(Parser):
|
|||||||
if self.opts.remove_paragraph_spacing:
|
if self.opts.remove_paragraph_spacing:
|
||||||
css += '\n\np {text-indent: 2em; margin-top:1pt; margin-bottom:1pt; padding:0pt; border:0pt;}'
|
css += '\n\np {text-indent: 2em; margin-top:1pt; margin-bottom:1pt; padding:0pt; border:0pt;}'
|
||||||
self.override_css = self.css_parser.parseString(self.preprocess_css(css))
|
self.override_css = self.css_parser.parseString(self.preprocess_css(css))
|
||||||
|
for rule in reversed(self.specified_override_css):
|
||||||
|
self.override_css.insertRule(rule, index=0)
|
||||||
|
|
||||||
|
|
||||||
def config(defaults=None, config_name='html',
|
def config(defaults=None, config_name='html',
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
<dc:contributor opf:role="bkp" py:with="attrs={'opf:files-as':__appname__}" py:attrs="attrs">${'%s (%s)'%(__appname__, __version__)} [http://${__appname__}.kovidgoyal.net]</dc:contributor>
|
<dc:contributor opf:role="bkp" py:with="attrs={'opf:files-as':__appname__}" py:attrs="attrs">${'%s (%s)'%(__appname__, __version__)} [http://${__appname__}.kovidgoyal.net]</dc:contributor>
|
||||||
<dc:identifier opf:scheme="${__appname__}" id="${__appname__}_id">${mi.application_id}</dc:identifier>
|
<dc:identifier opf:scheme="${__appname__}" id="${__appname__}_id">${mi.application_id}</dc:identifier>
|
||||||
|
|
||||||
<dc:language>${mi.language if mi.language else 'Unknown'}</dc:language>
|
<dc:language>${mi.language if mi.language else 'UND'}</dc:language>
|
||||||
<dc:type py:if="mi.category">${mi.category}</dc:type>
|
<dc:type py:if="mi.category">${mi.category}</dc:type>
|
||||||
<dc:description py:if="mi.comments">${mi.comments}</dc:description>
|
<dc:description py:if="mi.comments">${mi.comments}</dc:description>
|
||||||
<dc:publisher py:if="mi.publisher">${mi.publisher}</dc:publisher>
|
<dc:publisher py:if="mi.publisher">${mi.publisher}</dc:publisher>
|
||||||
|
@ -474,7 +474,7 @@ class BasicNewsRecipe(object, LoggingInterface):
|
|||||||
if self.extra_css is not None:
|
if self.extra_css is not None:
|
||||||
head = soup.find('head')
|
head = soup.find('head')
|
||||||
if head:
|
if head:
|
||||||
style = BeautifulSoup(u'<style type="text/css">%s</style>'%self.extra_css).find('style')
|
style = BeautifulSoup(u'<style type="text/css" title="override_css">%s</style>'%self.extra_css).find('style')
|
||||||
head.insert(len(head.contents), style)
|
head.insert(len(head.contents), style)
|
||||||
if first_fetch and job_info:
|
if first_fetch and job_info:
|
||||||
url, f, a, feed_len = job_info
|
url, f, a, feed_len = job_info
|
||||||
|
@ -16,8 +16,8 @@ class TheAtlantic(BasicNewsRecipe):
|
|||||||
INDEX = 'http://www.theatlantic.com/doc/current'
|
INDEX = 'http://www.theatlantic.com/doc/current'
|
||||||
|
|
||||||
remove_tags_before = dict(name='div', id='storytop')
|
remove_tags_before = dict(name='div', id='storytop')
|
||||||
remove_tags = [dict(name='div', id='seealso')]
|
remove_tags = [dict(name='div', id=['seealso', 'storybottom', 'footer'])]
|
||||||
extra_css = '#bodytext {line-height: 1}'
|
no_stylesheets = True
|
||||||
|
|
||||||
def parse_index(self):
|
def parse_index(self):
|
||||||
articles = []
|
articles = []
|
||||||
|
@ -102,7 +102,7 @@ def build_osx(shutdown=True):
|
|||||||
def build_linux(shutdown=True):
|
def build_linux(shutdown=True):
|
||||||
installer = installer_name('tar.bz2')
|
installer = installer_name('tar.bz2')
|
||||||
vm = '/vmware/linux/libprs500-gentoo.vmx'
|
vm = '/vmware/linux/libprs500-gentoo.vmx'
|
||||||
start_vm(vm, 'linux', (BUILD_SCRIPT%('sudo python setup.py develop', 'python','installer/linux/freeze.py')).replace('rm ', 'sudo rm '), sleep=100)
|
start_vm(vm, 'linux', (BUILD_SCRIPT%('sudo python setup.py develop', 'python','installer/linux/freeze.py')).replace('rm ', 'sudo rm '), sleep=120)
|
||||||
subprocess.check_call(('scp', 'linux:/tmp/%s'%os.path.basename(installer), 'dist'))
|
subprocess.check_call(('scp', 'linux:/tmp/%s'%os.path.basename(installer), 'dist'))
|
||||||
if not os.path.exists(installer):
|
if not os.path.exists(installer):
|
||||||
raise Exception('Failed to build installer '+installer)
|
raise Exception('Failed to build installer '+installer)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user