summaryrefslogtreecommitdiff
path: root/src/xhtml.py
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2012-02-15 20:10:00 +0100
committerFlorent Le Coz <louiz@louiz.org>2012-02-15 20:10:00 +0100
commit695a7ebebaf6a277420dcb42cd96d92d77df0379 (patch)
tree8c9da1e5bf988356ad110f42113949aab94a5866 /src/xhtml.py
parent0606c2b351ac87f110e1240d2f4ba1b94b275930 (diff)
parentb89cd8fd8322bf8aa23130398a0a70defcba708d (diff)
downloadpoezio-695a7ebebaf6a277420dcb42cd96d92d77df0379.tar.gz
poezio-695a7ebebaf6a277420dcb42cd96d92d77df0379.tar.bz2
poezio-695a7ebebaf6a277420dcb42cd96d92d77df0379.tar.xz
poezio-695a7ebebaf6a277420dcb42cd96d92d77df0379.zip
Merge branch 'master' of https://git.louiz.org/poezio
Diffstat (limited to 'src/xhtml.py')
-rw-r--r--src/xhtml.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/xhtml.py b/src/xhtml.py
index e7a045fa..cf7a5fc0 100644
--- a/src/xhtml.py
+++ b/src/xhtml.py
@@ -194,7 +194,9 @@ def get_body_from_message_stanza(message):
if config.get('enable_xhtml_im', 'true') == 'true':
xhtml_body = message['xhtml_im']
if xhtml_body:
- return xhtml_to_poezio_colors(xhtml_body)
+ content = xhtml_to_poezio_colors(xhtml_body)
+ content = content if content else message['body']
+ return content or " "
return message['body']
def ncurses_color_to_html(color):
@@ -288,9 +290,9 @@ def xhtml_to_poezio_colors(text):
for elem in elems:
if elem.tag == '{http://www.w3.org/1999/xhtml}a':
if 'href' in elem.attrib and elem.attrib['href'] != elem.text:
- message += '\x19u%s\x19o (%s)' % (trim(elem.attrib['href']), trim(elem.text))
+ message += '\x19u%s\x19o (%s)' % (trim(elem.attrib['href']), trim(elem.text if elem.text else ""))
else:
- message += '\x19u' + elem.text + '\x19o'
+ message += '\x19u' + (elem.text if elem.text else "") + '\x19o'
elif elem.tag == '{http://www.w3.org/1999/xhtml}blockquote':
message += '“'
elif elem.tag == '{http://www.w3.org/1999/xhtml}body':