From eaba5aa228cbcd9e53dba7d092a284b94e7fa6b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Thu, 20 Nov 2014 12:51:30 +0100 Subject: [PATCH] odf2legi: handle spans containing soft-breaks (#5978) --- odf2legi/odf2legi.py | 6 +++++- odf2legi/tests.py | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/odf2legi/odf2legi.py b/odf2legi/odf2legi.py index feef1ef..81751a8 100644 --- a/odf2legi/odf2legi.py +++ b/odf2legi/odf2legi.py @@ -265,7 +265,11 @@ def fill_inline(para, elem, invert_bg=False): para.getchildren()[-1].tail = '' para.getchildren()[-1].tail += elem.text.strip('\n') else: - para.text = elem.text.strip('\n') + if para.text: + orig = para.text + else: + orig = '' + para.text = orig + elem.text.strip('\n') for child in elem.getchildren(): if child.tag == '{%s}span' % TEXT_NS and child.getchildren(): diff --git a/odf2legi/tests.py b/odf2legi/tests.py index bc78370..6c4124b 100644 --- a/odf2legi/tests.py +++ b/odf2legi/tests.py @@ -164,6 +164,26 @@ Plop foobar@example.net plop ''' self.assertEqual(self.convert_to_legi(doc), '''Plop foobar@example.net plop\n''') + def test_inline_many_spans(self): + doc = '''\ + +Plop plop plop\ +''' + self.assertEqual(self.convert_to_legi(doc), '''Plop plop plop''') + + def test_inline_many_spans_s(self): + # appears in https://dev.entrouvert.org/issues/5978 + doc = '''\ + +Plop plop plop plop\ +''' + self.assertEqual(self.convert_to_legi(doc), '''Plop plop plop plop''') + + class TableTestCase(unittest.TestCase):