From 21eeef5c7b83e5c7106a18b12ba5f423d321e186 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Sun, 29 Jul 2012 03:36:05 +0200 Subject: Implement the sending of underlined text in xhtml-im messages (C-c u). Note that a portion of text can NOT have a color AND be underlined at the same time, but it's not really tragic (see comment in source code). --- src/xhtml.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/xhtml.py b/src/xhtml.py index 4d93a855..a36607d2 100644 --- a/src/xhtml.py +++ b/src/xhtml.py @@ -399,7 +399,12 @@ def poezio_colors_to_html(string): Convert poezio colors to html makups (e.g. \x191: ) """ - # TODO underlined + # XXX: You cannot underline AND use color on the same portion of your + # message (because both these things use a element, and the + # current way it is done, when you open a element, you close the + # previous one). Dectecting if a span is already opened, close it and + # reopen it with the same style PLUS the new style seems complicated. + # I'll keep it that way unless someone fixes that properly. # a list of all opened elements, e.g. ['strong', 'span'] # So that we know what we need to close @@ -418,6 +423,15 @@ def poezio_colors_to_html(string): if 'strong' not in opened_elements: opened_elements.append('strong') res += '' + elif attr_char == 'u': + if 'strong' in opened_elements: + res += '' + opened_elements.remove('strong') + if 'span' in opened_elements: + res += '' + else: + opened_elements.append('span') + res += "" if attr_char in digits: number_str = string[next_attr_char+1:string.find('}', next_attr_char)] number = int(number_str) -- cgit v1.2.3