# HG changeset patch # User Goffi # Date 1383989043 -3600 # Node ID d7c41c84d062b8dcad07a8fc2bb7844e869d1d06 # Parent 43881c3dda9d61c2215b0644fb7283bf75e10818 browser side: use of inlineRoot to display XHTML chat text diff -r 43881c3dda9d -r d7c41c84d062 browser_side/panels.py --- a/browser_side/panels.py Sat Nov 09 10:23:33 2013 +0100 +++ b/browser_side/panels.py Sat Nov 09 10:24:03 2013 +0100 @@ -43,7 +43,7 @@ from radiocol import RadioColPanel from menu import Menu from jid import JID -from tools import html_sanitize, addURLToText +from tools import html_sanitize, addURLToText, inlineRoot from datetime import datetime from time import time import dialog @@ -619,7 +619,7 @@ {"timestamp": _date.strftime("%H:%M"), "nick": "[%s]" % html_sanitize(nick), "msg_class": ' '.join(_msg_class), - "msg": addURLToText(html_sanitize(msg)) if not xhtml else xhtml} #FIXME: images and external links must be removed according to preferences + "msg": addURLToText(html_sanitize(msg)) if not xhtml else inlineRoot(xhtml)} #FIXME: images and external links must be removed according to preferences ) self.setStyleName('chatText') diff -r 43881c3dda9d -r d7c41c84d062 browser_side/tools.py --- a/browser_side/tools.py Sat Nov 09 10:23:33 2013 +0100 +++ b/browser_side/tools.py Sat Nov 09 10:24:03 2013 +0100 @@ -21,12 +21,21 @@ from pyjamas.ui.DragWidget import DragWidget import re +from nativedom import NativeDOM +from sat.tools.frontends import xml + +dom = NativeDOM() def html_sanitize(html): """Naive sanitization of HTML""" return html.replace('<','<').replace('>','>') +def inlineRoot(xhtml): + """ make root element inline """ + doc = dom.parseString(xhtml) + return xml.inlineRoot(doc) + def addURLToText(string): """Check a text for what looks like an URL and make it clickable. Regexp from http://daringfireball.net/2010/07/improved_regex_for_matching_urls"""