fix printing HTML messages. Fixes #5298

This commit is contained in:
Yann Leboulanger 2009-10-02 17:57:17 +02:00
parent b954492bc2
commit ca127b8d31
2 changed files with 16 additions and 10 deletions

View File

@ -1119,8 +1119,11 @@ class ConversationTextview(gobject.GObject):
# It's nothing special
if use_other_tags:
end_iter = buffer_.get_end_iter()
buffer_.insert_with_tags_by_name(end_iter, special_text,
*other_tags)
insert_tags_func = buffer_.insert_with_tags_by_name
if len(other_tags) > 0 and isinstance(other_tags[0], gtk.TextTag):
insert_tags_func = buffer_.insert_with_tags
insert_tags_func(end_iter, special_text, *other_tags)
if len(tags) > 0:
end_iter = buffer_.get_end_iter()
@ -1290,14 +1293,14 @@ class ConversationTextview(gobject.GObject):
graphics=True):
'''this adds normal and special text. call this to add text'''
if xhtml:
try:
if name and (text.startswith('/me ') or text.startswith('/me\n')):
xhtml = xhtml.replace('/me', '<i>* %s</i>' % (name,), 1)
self.tv.display_html(xhtml.encode('utf-8'), self)
return
except Exception, e:
gajim.log.debug(str('Error processing xhtml') + str(e))
gajim.log.debug(str('with |' + xhtml + '|'))
# try:
if name and (text.startswith('/me ') or text.startswith('/me\n')):
xhtml = xhtml.replace('/me', '<i>* %s</i>' % (name,), 1)
self.tv.display_html(xhtml.encode('utf-8'), self)
return
# except Exception, e:
# gajim.log.debug(str('Error processing xhtml') + str(e))
# gajim.log.debug(str('with |' + xhtml + '|'))
# /me is replaced by name if name is given
if name and (text.startswith('/me ') or text.startswith('/me\n')):

View File

@ -951,12 +951,15 @@ if __name__ == '__main__':
' <span style="font-size: 500%; font-family: serif">World</span>\n'
'</div>\n')
htmlview.print_real_text(None, xhtml='<hr />')
htmlview.print_real_text(None, xhtml='''<body xmlns='http://www.w3.org/1999/xhtml'><p xmlns='http://www.w3.org/1999/xhtml'>a:b<a href='http://google.com/' xmlns='http://www.w3.org/1999/xhtml'>Google</a></p><br/></body>''')
htmlview.print_real_text(None, xhtml='''
<body xmlns='http://www.w3.org/1999/xhtml'>
<p style='font-size:large'>
<span style='font-style: italic'>O<span style='font-size:larger'>M</span>G</span>,
I&apos;m <span style='color:green'>green</span>
with <span style='font-weight: bold'>envy</span>!
</p>
</body>
''')
htmlview.print_real_text(None, xhtml='<hr />')
htmlview.print_real_text(None, xhtml='''