Mercurial > libervia-backend
comparison 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 |
comparison
equal
deleted
inserted
replaced
1732:cf11cfc87ef9 | 1733:3770d13776e8 |
---|---|
1359 @param text(unicode) | 1359 @param text(unicode) |
1360 @return unicode | 1360 @return unicode |
1361 """ | 1361 """ |
1362 # if present, replace <br> (HTML), <br > and <br/> at end of line with <br /> (XHTML) | 1362 # if present, replace <br> (HTML), <br > and <br/> at end of line with <br /> (XHTML) |
1363 return re.sub(r"<br[ ]?/?>\n", "\n", text).replace("\n", "<br />\n") | 1363 return re.sub(r"<br[ ]?/?>\n", "\n", text).replace("\n", "<br />\n") |
1364 | |
1365 | |
1366 def decapsulateDomishContent(elt): | |
1367 """Return the inner content of a domish.Element. | |
1368 | |
1369 @return unicode | |
1370 """ | |
1371 result = '' | |
1372 for child in elt.children: | |
1373 try: | |
1374 result += child.toXml() # child id a domish.Element | |
1375 except AttributeError: | |
1376 result += child # child is unicode | |
1377 return result |