From d14fcbd1c8e8a5dafe7124686b07cdc4e45d653e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Thu, 24 Apr 2014 15:27:12 +0200 Subject: [PATCH] do not lose paragraph text when it's set in many s (#4254) --- odf2legi/odf2legi.py | 7 ++++++- odf2legi/tests.py | 47 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/odf2legi/odf2legi.py b/odf2legi/odf2legi.py index 28ce406..12b307a 100644 --- a/odf2legi/odf2legi.py +++ b/odf2legi/odf2legi.py @@ -257,7 +257,12 @@ def fill_inline(para, elem, invert_bg=False): ''' if elem.text: - para.text = elem.text.strip('\n') + if para.getchildren(): + if para.getchildren()[-1].tail is None: + para.getchildren()[-1].tail = '' + para.getchildren()[-1].tail += elem.text.strip('\n') + else: + para.text = 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 4288779..337d1e1 100644 --- a/odf2legi/tests.py +++ b/odf2legi/tests.py @@ -142,6 +142,18 @@ Plop self.assertEqual(self.convert_to_legi(doc), '''FooBar. Baz''') + def test_footnotes_bug4254bis(self): + doc = '''\ +Foo +2Bar. Baz +''' + + self.assertEqual(self.convert_to_legi(doc), + '''FooBar. Baz''') + class TableTestCase(unittest.TestCase): @@ -458,6 +470,41 @@ class ListTestCase(unittest.TestCase): odf2legi.convert_to_legi_xml(doc), '''ChapterPremiere listeSecond niveauTres simple''') + def test_list_with_footnote(self): + doc = '''\ + + + + + + + + + + + + +Chapter + + + Premiere2Bar. liste + + + + + +''' + self.assertEqual( + odf2legi.convert_to_legi_xml(doc), + '''ChapterPremiereBar. liste''') + class FigureTestCase(unittest.TestCase): def test_figure(self):