Mercurial > libervia-backend
changeset 1802:fed95a6c56f8
plugin (xep-0277): avoid wrapping XML in an extra <div> in data2entry
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 15 Jan 2016 17:13:59 +0100 (2016-01-15) |
parents | 07390a9d1c09 |
children | 14a97a5fe1c0 |
files | src/plugins/plugin_xep_0277.py |
diffstat | 1 files changed, 8 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0277.py Fri Jan 15 12:27:34 2016 +0100 +++ b/src/plugins/plugin_xep_0277.py Fri Jan 15 17:13:59 2016 +0100 @@ -370,7 +370,14 @@ 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