mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Conversion: Fix the obsolete HTML align=center markup (produced by Microsoft Word) not working for tables. Fixes #1569583 [table alignment lost on conversion](https://bugs.launchpad.net/calibre/+bug/1569583)
This commit is contained in:
parent
602902476d
commit
d8bfb8c8b1
@ -344,6 +344,20 @@ class CSSFlattener(object):
|
||||
if 'align' in node.attrib:
|
||||
if tag != 'img':
|
||||
cssdict['text-align'] = node.attrib['align']
|
||||
if cssdict['text-align'] == 'center':
|
||||
# align=center causes tables to be center aligned,
|
||||
# which text-align does not. And the ever trustworthy Word
|
||||
# uses this construct in its HTML output. See
|
||||
# https://bugs.launchpad.net/bugs/1569583
|
||||
if tag == 'table':
|
||||
if 'margin-left' not in cssdict and 'margin-right' not in cssdict:
|
||||
cssdict['margin-left'] = cssdict['margin-right'] = 'auto'
|
||||
else:
|
||||
for table in node.iterchildren(XHTML("table")):
|
||||
ts = stylizer.style(table)
|
||||
if ts.get('margin-left') is None and ts.get('margin-right') is None:
|
||||
ts.set('margin-left', 'auto')
|
||||
ts.set('margin-right', 'auto')
|
||||
else:
|
||||
val = node.attrib['align']
|
||||
if val in ('middle', 'bottom', 'top'):
|
||||
|
Loading…
x
Reference in New Issue
Block a user