Mercurial > libervia-web
diff src/browser/sat_browser/html_tools.py @ 504:f030491cff75
browser side (XMLUI): fixed bad use of text instead of XHTML in dialogs
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 20 Aug 2014 20:59:13 +0200 |
parents | 97c72fe4a5f2 |
children | e876f493dccc |
line wrap: on
line diff
--- a/src/browser/sat_browser/html_tools.py Thu Aug 14 13:27:07 2014 +0200 +++ b/src/browser/sat_browser/html_tools.py Wed Aug 20 20:59:13 2014 +0200 @@ -29,19 +29,20 @@ """Naive sanitization of HTML""" return html.replace('<', '<').replace('>', '>') - def html_strip(html): """Strip leading/trailing white spaces, HTML line breaks and sequences.""" cleaned = re.sub(r"^(<br/?>| |\s)+", "", html) cleaned = re.sub(r"(<br/?>| |\s)+$", "", cleaned) return cleaned - def inlineRoot(xhtml): """ make root element inline """ doc = dom.parseString(xhtml) return xmltools.inlineRoot(doc) - def convertNewLinesToXHTML(text): return text.replace('\n', '<br/>') + +def XHTML2Text(xhtml): + """Helper method to apply both html_sanitize and convertNewLinesToXHTML""" + return convertNewLinesToXHTML(html_sanitize(xhtml))