From 8b825d4055e528c0d79cc786b4504213741f298c Mon Sep 17 00:00:00 2001 From: Goffi Date: Fri, 15 Jan 2016 17:13:59 +0100 Subject: [PATCH] plugin (xep-0277): avoid wrapping XML in an extra
in data2entry --- src/plugins/plugin_xep_0277.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/plugins/plugin_xep_0277.py b/src/plugins/plugin_xep_0277.py index 8e8f912e..166f2c87 100755 --- a/src/plugins/plugin_xep_0277.py +++ b/src/plugins/plugin_xep_0277.py @@ -370,7 +370,14 @@ class XEP_0277(object): xml_content = u'
{converted}
'.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
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