xml_tools, plugin XEP-0071, XEP-0277: add method expandNewLinesToXHTML:
- \n in XHTML content should not be converted to <br /> by the frontend
- save it directly in the Atom payload for better compatibility with other clients
This commit is contained in:
parent
17476b420c
commit
ca5c913ce2
1 changed files with 15 additions and 1 deletions
|
|
@ -29,7 +29,7 @@ from twisted.words.protocols.jabber import jid
|
|||
from twisted.internet import defer
|
||||
from sat.core import exceptions
|
||||
from collections import OrderedDict
|
||||
|
||||
import re
|
||||
|
||||
"""This library help manage XML used in SàT (parameters, registration, etc)"""
|
||||
|
||||
|
|
@ -1351,3 +1351,13 @@ class ElementParser(object):
|
|||
tmp.addRawXml(raw_xml)
|
||||
parser.parse(tmp.toXml().encode('utf-8'))
|
||||
return self.result.firstChildElement()
|
||||
|
||||
|
||||
def expandNewLinesToXHTML(text):
|
||||
"""If not present yet, add a <br /> before all \n occurences.
|
||||
|
||||
@param text(unicode)
|
||||
@return unicode
|
||||
"""
|
||||
# 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")
|
||||
|
|
|
|||
Loading…
Reference in a new issue