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.replace_page_breaks()
|
||||||
self.cleanup_html()
|
self.cleanup_html()
|
||||||
|
|
||||||
self.processed_html = re.compile('<head>', re.IGNORECASE).sub(
|
self.processed_html = \
|
||||||
'<head>\n<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />\n',
|
re.compile('<head>', re.IGNORECASE).sub(
|
||||||
self.processed_html)
|
'<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<'))
|
soup = BeautifulSoup(self.processed_html.replace('> <', '>\n<'))
|
||||||
self.cleanup_soup(soup)
|
self.cleanup_soup(soup)
|
||||||
@ -214,6 +220,11 @@ class MobiReader(object):
|
|||||||
del tag['width']
|
del tag['width']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
try:
|
||||||
|
styles.append('text-align: %s' % tag['align'])
|
||||||
|
del tag['align']
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
if styles:
|
if styles:
|
||||||
tag['style'] = '; '.join(styles)
|
tag['style'] = '; '.join(styles)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user