odf2legi: handle spans containing soft-breaks (#5978)
This commit is contained in:
parent
9531583e6a
commit
eaba5aa228
|
@ -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():
|
||||
|
|
|
@ -164,6 +164,26 @@ Plop <text:a>foobar@example.net</text:a> plop
|
|||
</text:p>'''
|
||||
self.assertEqual(self.convert_to_legi(doc), '''<para>Plop foobar@example.net plop\n</para>''')
|
||||
|
||||
def test_inline_many_spans(self):
|
||||
doc = '''\
|
||||
<text:p xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
|
||||
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
|
||||
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0">
|
||||
<text:span>Plop</text:span> <text:span>plop</text:span> <text:span>plop</text:span>\
|
||||
</text:p>'''
|
||||
self.assertEqual(self.convert_to_legi(doc), '''<para>Plop plop plop</para>''')
|
||||
|
||||
def test_inline_many_spans_s(self):
|
||||
# appears in https://dev.entrouvert.org/issues/5978
|
||||
doc = '''\
|
||||
<text:p xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
|
||||
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
|
||||
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0">
|
||||
<text:span>Plop</text:span> <text:span>plop <text:s/>plop</text:span> <text:span>plop</text:span>\
|
||||
</text:p>'''
|
||||
self.assertEqual(self.convert_to_legi(doc), '''<para>Plop plop plop plop</para>''')
|
||||
|
||||
|
||||
|
||||
|
||||
class TableTestCase(unittest.TestCase):
|
||||
|
|
Reference in New Issue