summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2014-02-22 01:11:57 +0100
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2014-02-22 01:11:57 +0100
commita64dd02118630365cf55a4e8dd90429f1ef49a0f (patch)
treef4bfc1ea8e52cf6858a460080107a9944007eb54 /src
parent9240bc396465817c6387de5392f6dc2d429a8bd7 (diff)
downloadpoezio-a64dd02118630365cf55a4e8dd90429f1ef49a0f.tar.gz
poezio-a64dd02118630365cf55a4e8dd90429f1ef49a0f.tar.bz2
poezio-a64dd02118630365cf55a4e8dd90429f1ef49a0f.tar.xz
poezio-a64dd02118630365cf55a4e8dd90429f1ef49a0f.zip
Remove the dependency on poezio from xhtml.py
Diffstat (limited to 'src')
-rw-r--r--src/core.py13
-rw-r--r--src/xhtml.py7
2 files changed, 10 insertions, 10 deletions
diff --git a/src/core.py b/src/core.py
index f9c6d5e3..af0c6348 100644
--- a/src/core.py
+++ b/src/core.py
@@ -2941,7 +2941,8 @@ class Core(object):
elif message['type'] == 'headline' and message['body']:
return self.information('%s says: %s' % (message['from'], message['body']), 'Headline')
- body = xhtml.get_body_from_message_stanza(message)
+ use_xhtml = config.get('enable_xhtml_im', 'true') == 'true'
+ body = xhtml.get_body_from_message_stanza(message, use_xhtml=use_xhtml)
if not body:
return
@@ -2983,7 +2984,7 @@ class Core(object):
self.events.trigger('conversation_msg', message, conversation)
if not message['body']:
return
- body = xhtml.get_body_from_message_stanza(message)
+ body = xhtml.get_body_from_message_stanza(message, use_xhtml=use_xhtml)
delayed, date = common.find_delayed_tag(message)
def try_modify():
@@ -3199,7 +3200,8 @@ class Core(object):
return
self.events.trigger('muc_msg', message, tab)
- body = xhtml.get_body_from_message_stanza(message)
+ use_xhtml = config.get('enable_xhtml_im', 'true') == 'true'
+ body = xhtml.get_body_from_message_stanza(message, use_xhtml=use_xhtml)
if not body:
return
@@ -3246,7 +3248,8 @@ class Core(object):
return self.on_groupchat_message(message)
room_from = jid.bare
- body = xhtml.get_body_from_message_stanza(message)
+ use_xhtml = config.get('enable_xhtml_im', 'true') == 'true'
+ body = xhtml.get_body_from_message_stanza(message, use_xhtml=use_xhtml)
tab = self.get_tab_by_name(jid.full, tabs.PrivateTab) # get the tab with the private conversation
ignore = config.get_by_tabname('ignore_private', 'false',
room_from).lower() == 'true'
@@ -3260,7 +3263,7 @@ class Core(object):
self.xmpp.send_message(mto=jid.full, mbody=msg, mtype='chat')
return
self.events.trigger('private_msg', message, tab)
- body = xhtml.get_body_from_message_stanza(message)
+ body = xhtml.get_body_from_message_stanza(message, use_xhtml=use_xhtml)
if not body or not tab:
return
replaced_id = message['replace']['id']
diff --git a/src/xhtml.py b/src/xhtml.py
index a1628574..85e764ba 100644
--- a/src/xhtml.py
+++ b/src/xhtml.py
@@ -20,9 +20,6 @@ from io import BytesIO
from xml import sax
from xml.sax import saxutils
-from config import config
-import logging
-
digits = '0123456789' # never trust the modules
XHTML_NS = 'http://www.w3.org/1999/xhtml'
@@ -184,13 +181,13 @@ xhtml_attr_re = re.compile(r'\x19-?\d[^}]*}|\x19[buaio]')
xhtml_simple_attr_re = re.compile(r'\x19\d')
-def get_body_from_message_stanza(message):
+def get_body_from_message_stanza(message, use_xhtml=False):
"""
Returns a string with xhtml markups converted to
poezio colors if there's an xhtml_im element, or
the body (without any color) otherwise
"""
- if config.get('enable_xhtml_im', 'true') == 'true':
+ if use_xhtml:
xhtml = message['html'].xml
xhtml_body = xhtml.find('{http://www.w3.org/1999/xhtml}body')
if xhtml_body: