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):