From c198458f654ab170b126e22d5dff4c7b6cd61aa0 Mon Sep 17 00:00:00 2001 From: "Marshall T. Vandegrift" Date: Mon, 19 Jan 2009 22:33:58 -0500 Subject: [PATCH] Improve Mobipocket conversion of basic tables --- src/calibre/ebooks/mobi/mobiml.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/calibre/ebooks/mobi/mobiml.py b/src/calibre/ebooks/mobi/mobiml.py index 720bb3df8f..afc2fb63ba 100644 --- a/src/calibre/ebooks/mobi/mobiml.py +++ b/src/calibre/ebooks/mobi/mobiml.py @@ -140,7 +140,7 @@ class MobiMLizer(object): para = bstate.para if tag in SPECIAL_TAGS and not text: para = para if para is not None else bstate.body - elif para is None: + elif para is None or tag in ('td', 'th'): body = bstate.body if bstate.pbreak: etree.SubElement(body, MBP('pagebreak')) @@ -160,7 +160,8 @@ class MobiMLizer(object): elif indent != 0 and abs(indent) < self.profile.fbase: indent = (indent / abs(indent)) * self.profile.fbase if tag in NESTABLE_TAGS: - para = wrapper = etree.SubElement(parent, XHTML(tag)) + para = wrapper = etree.SubElement( + parent, XHTML(tag), attrib=istate.attrib) bstate.nested.append(para) if tag == 'li' and len(istates) > 1: istates[-2].list_num += 1 @@ -340,6 +341,10 @@ class MobiMLizer(object): tag = 'tr' elif display == 'table-cell': tag = 'td' + if tag in TABLE_TAGS: + for attr in ('rowspan', 'colspan'): + if attr in elem.attrib: + istate.attrib[attr] = elem.attrib[attr] text = None if elem.text: if istate.preserve: @@ -377,6 +382,6 @@ class MobiMLizer(object): bstate.vpadding += bstate.vmargin bstate.vmargin = 0 bstate.vpadding += vpadding - if tag in NESTABLE_TAGS and bstate.nested: + if bstate.nested and bstate.nested[-1].tag == elem.tag: bstate.nested.pop() istates.pop()