From 492d16e5c996418ec311cfc5a1a2462b1889eaea Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 3 Apr 2011 14:31:14 -0600 Subject: [PATCH] ODT Input: Fix handling of the element. Fixes #749655 (Private bug) --- src/odf/odf2xhtml.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/odf/odf2xhtml.py b/src/odf/odf2xhtml.py index 390d407d16..26da9d9905 100644 --- a/src/odf/odf2xhtml.py +++ b/src/odf/odf2xhtml.py @@ -1386,12 +1386,19 @@ ol, ul { padding-left: 2em; } self.purgedata() def s_text_s(self, tag, attrs): - """ Generate a number of spaces. ODF has an element; HTML uses   - We use   so we can send the output through an XML parser if we desire to + # Changed by Kovid to fix non breaking spaces being prepended to + # element instead of being part of the text flow. + # We don't use an entity for the nbsp as the contents of self.data will + # be escaped on writeout. + """ Generate a number of spaces. We use the non breaking space for + the text:s ODF element. """ - c = attrs.get( (TEXTNS,'c'),"1") - for x in xrange(int(c)): - self.writeout(' ') + try: + c = int(attrs.get((TEXTNS, 'c'), 1)) + except: + c = 0 + if c > 0: + self.data.append(u'\u00a0'*c) def s_text_span(self, tag, attrs): """ The element matches the element in HTML. It is