Fix whitespace handling in XHTML.
This commit is contained in:
parent
e37f98aa5d
commit
8845cdce8e
1 changed files with 4 additions and 4 deletions
|
@ -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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue