Mercurial > libervia-web
changeset 405:41b8b96f2248
browser_side: display new lines in microblogs (convert '\n' to '<br/>')
author | souliane <souliane@mailoo.org> |
---|---|
date | Sat, 15 Mar 2014 00:33:04 +0100 |
parents | c393e7dc9ae6 |
children | 63f8469b4ad3 |
files | browser_side/base_panels.py browser_side/html_tools.py |
diffstat | 2 files changed, 6 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/browser_side/base_panels.py Sat Mar 15 00:21:04 2014 +0100 +++ b/browser_side/base_panels.py Sat Mar 15 00:33:04 2014 +0100 @@ -37,7 +37,7 @@ from datetime import datetime from time import time -from html_tools import html_sanitize, html_strip, inlineRoot +from html_tools import html_sanitize, html_strip, inlineRoot, convertNewLinesToXHTML from sat_frontends.tools.strings import addURLToText, addURLToImage from sat.core.i18n import _ @@ -505,7 +505,7 @@ text = addURLToImage(text) if self.options['enhance_display']: text = addURLToText(text) - self.display.setHTML(text) + self.display.setHTML(convertNewLinesToXHTML(text)) def setFocus(self, focus): raise NotImplementedError
--- a/browser_side/html_tools.py Sat Mar 15 00:21:04 2014 +0100 +++ b/browser_side/html_tools.py Sat Mar 15 00:33:04 2014 +0100 @@ -40,3 +40,7 @@ """ make root element inline """ doc = dom.parseString(xhtml) return xmltools.inlineRoot(doc) + + +def convertNewLinesToXHTML(text): + return text.replace('\n', '<br/>')