From 231df586c08b8d155a7996f6b000db65f7b438c3 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 11 May 2011 14:56:10 -0600 Subject: [PATCH] ODT Input: Handle inline special styles defined on tags. Fixes #780250 (Italic text not converting from ODT source) --- src/odf/odf2xhtml.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/odf/odf2xhtml.py b/src/odf/odf2xhtml.py index a04aa48bf7..0ae89b1663 100644 --- a/src/odf/odf2xhtml.py +++ b/src/odf/odf2xhtml.py @@ -1415,18 +1415,34 @@ ol, ul { padding-left: 2em; } self.writedata() c = attrs.get( (TEXTNS,'style-name'), None) htmlattrs = {} + # Changed by Kovid to handle inline apecial styles defined on tags. + # Apparently LibreOffice does this. + special = 'span' if c: c = c.replace(".","_") special = special_styles.get("S-"+c) - if special is None and self.generate_css: - htmlattrs['class'] = "S-%s" % c - self.opentag('span', htmlattrs) + if special is None: + special = 'span' + if self.generate_css: + htmlattrs['class'] = "S-%s" % c + + self.opentag(special, htmlattrs) self.purgedata() def e_text_span(self, tag, attrs): """ End the """ self.writedata() - self.closetag('span', False) + c = attrs.get( (TEXTNS,'style-name'), None) + # Changed by Kovid to handle inline apecial styles defined on tags. + # Apparently LibreOffice does this. + special = 'span' + if c: + c = c.replace(".","_") + special = special_styles.get("S-"+c) + if special is None: + special = 'span' + + self.closetag(special, False) self.purgedata() def s_text_tab(self, tag, attrs):