plugin (xep-0277): avoid wrapping XML in an extra <div> in data2entry

This commit is contained in:
Goffi 2016-01-15 17:13:59 +01:00
commit 8b825d4055

View file

@ -370,7 +370,14 @@ class XEP_0277(object):
xml_content = u'<div xmlns="{ns}">{converted}</div>'.format(
ns=NS_XHTML,
converted=converted)
elem.addChild(xml_tools.ElementParser()(xml_content))
div_elt = xml_tools.ElementParser()(xml_content)
if len(div_elt.children) == 1:
# if we have two <div> wrapping the content,
# we remove the one we have just added
child = div_elt.children[0]
if child.name == 'div' and not child.attributes and child.uri == div_elt.uri:
div_elt = child
elem.addChild(div_elt)
elem['type'] = 'xhtml'
if elem_name not in data:
# there is raw text content, which is mandatory