diff src/tools/xml_tools.py @ 1733:3770d13776e8

plugin XEP-0277, xml_tools: restore decapsulation of XHTML content - to avoid successive nesting of the content in <div> - otherwise there is a new <div> at each item modification
author souliane <souliane@mailoo.org>
date Thu, 10 Dec 2015 14:21:51 +0100
parents cf11cfc87ef9
children b2d6f3c92842
line wrap: on
line diff
--- a/src/tools/xml_tools.py	Thu Dec 10 14:00:21 2015 +0100
+++ b/src/tools/xml_tools.py	Thu Dec 10 14:21:51 2015 +0100
@@ -1361,3 +1361,17 @@
     """
     # if present, replace <br> (HTML), <br > and <br/> at end of line with <br /> (XHTML)
     return re.sub(r"<br[ ]?/?>\n", "\n", text).replace("\n", "<br />\n")
+
+
+def decapsulateDomishContent(elt):
+    """Return the inner content of a domish.Element.
+
+    @return unicode
+    """
+    result = ''
+    for child in elt.children:
+        try:
+            result += child.toXml()  # child id a domish.Element
+        except AttributeError:
+            result += child  # child is unicode
+    return result