mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add a basic inline stylesheet to Mobipocket books
This commit is contained in:
parent
318de321f1
commit
70ac293e17
@ -167,9 +167,15 @@ class MobiReader(object):
|
||||
self.replace_page_breaks()
|
||||
self.cleanup_html()
|
||||
|
||||
self.processed_html = re.compile('<head>', re.IGNORECASE).sub(
|
||||
'<head>\n<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />\n',
|
||||
self.processed_html)
|
||||
self.processed_html = \
|
||||
re.compile('<head>', re.IGNORECASE).sub(
|
||||
'<head>\n'
|
||||
'<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />\n'
|
||||
'<style type="text/css">\n'
|
||||
'blockquote { margin: 0em 0em 0em 1.25em; text-align: justify; }\n'
|
||||
'p { margin: 0em; text-align: justify; }\n'
|
||||
'</style>\n',
|
||||
self.processed_html)
|
||||
|
||||
soup = BeautifulSoup(self.processed_html.replace('> <', '>\n<'))
|
||||
self.cleanup_soup(soup)
|
||||
@ -214,6 +220,11 @@ class MobiReader(object):
|
||||
del tag['width']
|
||||
except KeyError:
|
||||
pass
|
||||
try:
|
||||
styles.append('text-align: %s' % tag['align'])
|
||||
del tag['align']
|
||||
except KeyError:
|
||||
pass
|
||||
if styles:
|
||||
tag['style'] = '; '.join(styles)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user