summaryrefslogtreecommitdiff
path: root/src/xhtml.py
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2011-09-23 00:20:34 +0200
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2011-09-23 00:20:34 +0200
commit8845cdce8e84004e5e4878bfad84ec59ea2f68ac (patch)
treeb509b3ff25d17e38b4520ce7a6964a9862017e09 /src/xhtml.py
parente37f98aa5de828b6c674af701814ba8386890af8 (diff)
downloadpoezio-8845cdce8e84004e5e4878bfad84ec59ea2f68ac.tar.gz
poezio-8845cdce8e84004e5e4878bfad84ec59ea2f68ac.tar.bz2
poezio-8845cdce8e84004e5e4878bfad84ec59ea2f68ac.tar.xz
poezio-8845cdce8e84004e5e4878bfad84ec59ea2f68ac.zip
Fix whitespace handling in XHTML.
Diffstat (limited to 'src/xhtml.py')
-rw-r--r--src/xhtml.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/xhtml.py b/src/xhtml.py
index eb0db829..fd50bb11 100644
--- a/src/xhtml.py
+++ b/src/xhtml.py
@@ -250,7 +250,7 @@ def xhtml_to_poezio_colors(text):
for elem in xml.iter():
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)' % (elem.attrib['href'], elem.text)
+ message += '\x19u%s\x19o (%s)' % (elem.attrib['href'].strip(), elem.text.strip())
else:
message += '\x19u' + elem.text + '\x19o'
elif elem.tag == '{http://www.w3.org/1999/xhtml}blockquote':
@@ -265,7 +265,7 @@ def xhtml_to_poezio_colors(text):
message += '\x19i'
elif elem.tag == '{http://www.w3.org/1999/xhtml}img' and 'src' in elem.attrib:
if 'alt' in elem.attrib:
- message += '%s (%s)' % (elem.attrib['src'], elem.attrib['alt'])
+ message += '%s (%s)' % (elem.attrib['src'].strip(), elem.attrib['alt'].strip())
else:
message += elem.attrib['src']
elif elem.tag == '{http://www.w3.org/1999/xhtml}li':
@@ -289,7 +289,7 @@ def xhtml_to_poezio_colors(text):
if (elem.text and elem.tag != '{http://www.w3.org/1999/xhtml}a'
and elem.tag != '{http://www.w3.org/1999/xhtml}br'
and elem.tag != '{http://www.w3.org/1999/xhtml}img'):
- message += elem.text
+ message += elem.text.strip()
if ('style' in elem.attrib and elem.tag != '{http://www.w3.org/1999/xhtml}br'
and elem.tag != '{http://www.w3.org/1999/xhtml}em'
@@ -311,7 +311,7 @@ def xhtml_to_poezio_colors(text):
message += ' [' + elem.attrib['title'] + ']'
if elem.tail:
- message += elem.tail
+ message += elem.tail.strip()
return message